- Trending Categories
- Data Structure
- Networking
- RDBMS
- Operating System
- Java
- MS Excel
- iOS
- HTML
- CSS
- Android
- Python
- C Programming
- C++
- C#
- MongoDB
- MySQL
- Javascript
- PHP
- Physics
- Chemistry
- Biology
- Mathematics
- English
- Economics
- Psychology
- Social Studies
- Fashion Studies
- Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Found 1082 Articles for Go Programming
235 Views
There can be some scenarios in which you have a list of employees and you need to display them in a particular order based on their salaries by sorting them. In this article we are going create a go program to sort the list of employees by salary using sort.slice() functions, sort.interface interface as well as using a custom sorting function. Syntax func len(v Type) int The len() method returns the length of any parameter. It accepts one input, the data type variable whose length we want to know, and returns the integer value that is the variable's length. ... Read More
168 Views
In this article, we will learn how to develop a golang program that takes a receiving channel as integer and sends a channel of strings. Here we will be using a concurrent approach that involves using the multiple goroutines to perform transformation concurrently as well as using select statements with timeout. Syntax channel_name := make(chan Type) To create a channel. channel_name
87 Views
Unidirectional channel is a type of channel that can only be used for either receiving or sending the data.In this article, we will create a golang program to detect a receiving channel that consist of string and a sending channel that has integers in it. Here we will learn how to utilize unidirectional channels to receive strings and send integers using unbuffered and buffered channels, select statements and using a struct to combine channels. Syntax ch := make(chan string) Creates a channel to handle strings. ch
230 Views
Unidirectional channel is a type of channel that will be either used for sending data or receiving data, but can’t be used for both. In this Golang article we will explore a Golang program that takes two unidirectional receiving channels and a sending channel using select statement as well as using a fan-in pattern method. We will provide code examples with algorithms and output of the code. Method 1: Using Select Statement This method allows you to handle multiple channel operations simultaneously and selecting the one which is ready to be processed. Algorithm Make three channels: channel one, channel ... Read More
Golang program to use a unidirectional channel to send integers from 1 to 10 to a receiving function
56 Views
In this go language article we are going to use a unidirectional channel to send integers from 1 to 10 to a receiving channel. We will be using a basic channel, a buffered channel with fixed capacity as well as using a select statement for non-blocking channel operation. Syntax ch := make (chan int) To create an unbuffered channel Value :=
180 Views
When working with go language channels there must be cases such as clear communication intent, enhanced safety in communication, encapsulation and more where you need to create unidirectional channels. In this go language article we are going to learn to create unidirectional channels using send only channel method, receive only channel method, using interfaces as well as type conversion methods. Bidirection channels enables the channel data to be transferred and received. There may be times when you want to impose unidirectional communication, limiting either sending or receiving actions. Syntax ch := make(chan
118 Views
Declaring an interface in go language means creating a new named type that defines a collection of method signatures. In go-language we can declare an interface using single method interface, multiple method interface as well as embedded interface. In this article we are going to understand these methods and declare an interface in go language with the help of various examples. Method 1: Single Method Interface The first method involves a single interface, in this approach we describe an interface that all implementing types must fulfill. Algorithm Create the interface with a single method called CreateSound(). Now, create ... Read More
107 Views
A priority queue is a queue in which elements are stored along with their priority values. The functions supported by priority queue are − enqueue and dequeue where enqueue implies adding elements to the queue along with their priorities and dequeue implies removing elements from the queue along with their priorities. In this article, we will write a Go language program to check if a priority queue is empty. Syntax func make ([] type, size, capacity) The make function in go language is used to create an array/map it accepts the type of variable to be created, its size ... Read More
98 Views
In this article, we will write a Go language program to insert a node into a Red Black tree. A Red Black tree. It is a self-balancing Binary search tree having the following properties − Every node is either red or black The root node is always black All leaves are taken as black If a node is red, both its children will be black Every path from a node to its descendant leaves contains the same number of black nodes Algorithm Create a "Node" struct with four fields: "key" of type int, "colour" of type string, ... Read More
257 Views
N queen problem is a puzzle in which N queens are to be placed on a NXN chessboard, so that the two queens don’t share the same row, column and diagonal or attack each other. A queen in chess can move in any direction, horizontally, vertically and diagonally so it is a challenge to find places where no two queens can attack each other. In this article, we will write a Go language program to implement the N queens problem. Syntax func make ([] type, size, capacity) The make function in go language is used to create an array/map ... Read More