- 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
979 Views
In this article, we will learn how to count the elements of a slice using a different set of examples. A slice is a sequence of elements just like an array. An array is a fixed sequence of elements whereas a slice is a dynamic array, meaning its value is not fixed and can be changed. Slices are more efficient and faster than arrays moreover; they are passed by reference instead by value. Let us learn through examples how it can be executed. Syntax func append(slice, element_1, element_2…, element_N) []T The append function is used to add values to ... Read More
1K+ Views
In this article, we will learn how to remove a null value from a slice using a variety of examples. A slice is a sequence of elements just like an array. An array is a fixed sequence of elements whereas a slice is a dynamic array, meaning its value is not fixed and can be changed. Slices are more efficient and faster than arrays moreover; they are passed by reference instead of value. Let us learn through examples how it can be executed. Method 1: Using For Loop In this method, we will see how to remove a null value ... Read More
173 Views
In this article, we will learn how to calculate the sum of right diagonal matrix with the help of different examples. A matrix is a 2-d array. The output will be printed on the screen using fmt.println() function which is a print statement in Golang. Algorithm Step 1 − Create a package main and declare fmt(format package) package in the program where main produces executable codes and fmt helps in formatting input and output. Step 2 − create a function main, in that function create a matrix, and fill with some values inside it. Step 3 − Print the ... Read More
189 Views
In this article, we will learn how to calculate the sum of left diagonal matrix with the help of different examples. A matrix is a 2-d array. The left diagonal matrix is printed using the logic of indexes equal to each other. The output will be printed on the screen using fmt.println() function which is a print statement in Golang. Algorithm Step 1 − Create a package main and declare fmt(format package) package in the program where main produces executable codes and fmt helps in formatting input and output. Step 2 − Create a function main and in that ... Read More
209 Views
In this article, we will see how to print the left diagonal matrix with the help of suitable examples. A matrix is a 2-d array. Here in the examples, we will use a nested for loop which will iterate through the rows and columns of the matrix to print the left diagonal matrix. The output will be printed on the screen using fmt.println() function which is a print statement in Golang. Algorithm Step 1 − Create a package main and declare fmt(format package) package in the program where main produces executable codes and fmt helps in formatting input and ... Read More
250 Views
In this article, we will see how to print the right diagonal matrix with the help of suitable examples. A matrix is a 2-d array. Here in the examples, we will use a nested for loop which will iterate through the rows and columns of the matrix to print the right diagonal matrix. The output will be printed on the screen using fmt.println() function which is a print statement in Golang. Algorithm Step 1 − Create a package main and declare fmt(format package) package in the program where main produces executable codes and fmt helps in formatting input and ... Read More
2K+ Views
In this article, we will learn how to initialize a slice using a variety of ways in examples. A slice is a sequence of elements just like an array. An array is a fixed sequence of elements whereas a slice is a dynamic array, meaning its value is not fixed and can be changed. Slices are more efficient and faster than arrays moreover they are passed by reference instead by value. Let’s learn through examples how it can be executed. Algorithm Step 1 − Create a package main and declare fmt(format package) package in the program where main produces ... Read More
4K+ Views
In this tutorial, we will execute the program of removing all the elements of array using different set of examples. An array is a well-defined collection of elements stored at contiguous memory locations. The output is printed in the screen using fmt.Println() function. Let’s see few examples to get a clear understanding of this concept. Syntax func append(slice, element_1, element_2…, element_N) []T The append function is used to add values to an array slice. It takes number of arguments. The first argument is the array to which we wish to add the values followed by the values to ... Read More
1K+ Views
In this tutorial, we will discuss how to obtain the first and last element from a slice. A slice is a dynamic-sequence that stores elements of a similar type. It is similar to array but it can be resized whereas an array is of fixed range. Let’s understand the concept using some examples. Method 1: Using integer values In this method, we will use integer values to get the first and last element from a slice. The output will be printed on the screen using fmt.Println() function. Let’s go through the example to understand how it can be done. Algorithm ... Read More
3K+ Views
In this tutorial, we will learn how to compare elements in two slices. In slices a simple equality comparison is not possible so the slices are compared with their lengths and the elements present in the loop. The output will be printed in the form of Boolean value on the console with the help of fmt.Println() function. Let’s see how to execute this with the help of an example. Method 1: Using a user-defined function In this method, we will compare elements in two slices using an external function and, in that function, we will set some conditions, if the ... Read More