In Go, a string is a sequence of characters. It is an immutable data type, meaning that once a string is created, it cannot be modified. Strings are enclosed in double quotes ("") and can contain any combination of letters, numbers, and symbols. They are commonly used to store text and are often used as input and output in programs. Syntax func len(v Type) int The len() function is used to get the length of a any parameter. It takes one parameter as the data type variable whose length we wish to find and returns the integer value ... Read More
A string in Golang is a collection of characters. Since strings in Go are immutable, they cannot be modified after they have been produced. Concatenating or adding to an existing string, however, enables the creation of new strings. A built-in type in Go, the string type can be used in a variety of ways much like any other data type. Algorithm Step 1 − Create a package main and declare fmt(format package) and sort package in the program where main produces executable codes and fmt helps in formatting input and output. Step 2 − Create a main function and ... Read More
An array is a fixed sequence of elements in which the elements are placed at contiguous memory locations. We will shuffle and randomly place the elements of the array. In the first case we will use fisher-yates shuffle algorithm. Let’s see how we can execute it using different logics in the Golang code. Syntax rand.Seed(value) Rand.Seed() function is used to generate random numbers. It takes a user input as argument which is the upper limit for generating random numbers. func Now() Time The Now() function is defined in time package. this function generates the current local time. to ... Read More
In go programming language, string is one of the data-types that can be used for various application. It is a collection of characters and is also immutable. In go programming language a string can't be modified after they have been created. In this article, we are going to study different techniques to compare two given strings. Syntax bytes.Equal(s1, s2) Two slices of bytes ([]byte) are compared using the Equal() method to see if they are equal. If the two slices of bytes are equal, it produces a boolean result (true or false) reflecting that fact. strings.Compare(s1, s2) The ... Read More
Slice is similar to an array, the only difference is that an array is a fixed sequence of elements whereas slice the array elements are dynamic. This makes the slice more efficient and faster in various applications. In slice, the elements are passed by reference instead of values. In this article, we will learn different techniques to remove a subset from slice using go language programming 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 ... Read More
A string in Golang is a collection of characters. Since strings in Go are immutable, they cannot be modified after they have been produced. Concatenating or adding to an existing string, however, enables the creation of new strings. A built-in type in Go, the string type can be used in a variety of ways much like any other data type. In this article, we will learn different techniques to sort a string using different set of examples. Syntax func Split(str, sep string) []string Split() function is used to split a string through a provided separator. This function is present ... Read More
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, which means 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. Here will learn various techniques to rotate elements of a slice using go programming language. 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 ... Read More
Slice is similar to the array, the only difference is that an array is a fixed sequence of elements whereas slice the array elements are dynamic. This makes slice more efficient and faster in various applications. In slice the elements are passed by reference instead of values. In this article, we are going to learn various techniques to check if a set of one slice is a subset of another slice or not using Go programming language. Algorithm Step 1 − Create a package main and declare fmt(format package) package in the program where main produces executable codes and ... Read More
A slice can also be called as a dynamic array as its value is dynamic whereas a normal array is static. This makes the slice more efficient and faster. They are passed by reference instead of value. Here we are going to learn different techniques of converting a slice into array using various examples. 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 add. The ... Read More
Strings are by default immutable in Go. A string cannot be changed once it has been created. A compile-time error will appear if the value of a string is attempted to be changed. Therefore, there is no need to add any more logic to make it immutable. Let’s see how the execution is done. Here we are going to learn different techniquest of making a string immutable using go programming. 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. ... Read More
Data Structure
Networking
RDBMS
Operating System
Java
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP