Server Side Programming Articles

Page 1669 of 2109

Golang Program to trim a string from the right side

Akhil Sharma
Akhil Sharma
Updated on 17-Feb-2023 3K+ Views

Strings are a built-in data type that represents sequences of characters in Golang. They are defined using double quotes (") and can contain any valid Unicode characters. In this article we will write a go language program to trim a string from the right side. We will achieve this both by using for loop and inbuilt library functions present in go language. Method 1: Using User-defined function In this method, the for loop is used to iterate over the string and then it compares the character of the string to the character from the right side to be removed. If ...

Read More

Golang Program to convert a string into Uppercase

Akhil Sharma
Akhil Sharma
Updated on 17-Feb-2023 4K+ Views

Strings are a built-in data type that represents sequences of characters in Golang. They are defined using double quotes (") and can contain any valid Unicode characters. In this article we will write a go language program to convert a string to uppercase. Here we will see the usage of both for loop and library functions to carry on the respective conversion. Method, 1: Using user-defined function In this method, we are going to create a user-defined function to convert a string into upper-case. The Steps to perform that are explained below − Algorithm Step 1 − First, we ...

Read More

Golang Program to trim a string from both sides

Akhil Sharma
Akhil Sharma
Updated on 17-Feb-2023 5K+ Views

Strings are a built-in data type that represents sequences of characters in Golang. They are defined using double quotes (") and can contain any valid Unicode characters. In this article we are going to learn about how to trim a string from both side using Go programming language. Method 1: By Using A For Loop In this method, the for loop is used to iterate over the string and then it compares the character of the string to the character of the string. If they are equal then remove that character from the string and print the remaining string. Algorithm ...

Read More

Golang Program to pad a string with 0's on left side

Akhil Sharma
Akhil Sharma
Updated on 17-Feb-2023 3K+ Views

In the Go programming language, strings are a built-in data type that represents sequences of characters. They are defined using double quotes (") and can contain any valid Unicode characters. In this article, we are going to learn different techniques to pad a string with 0’s on the left side. Method 1: Using User-defined function In this method, we will achieve this by creating an external function. The function accepts the string to be padded along with the length as argument and returns the final string after adding zeroes to left of it. Algorithm Step 1 − First, we ...

Read More

Golang Program to get the index of the substring in a string

Akhil Sharma
Akhil Sharma
Updated on 17-Feb-2023 4K+ Views

In the Go programming language, strings are a built-in data type that represents sequences of characters. They are defined using double quotes (") and can contain any valid Unicode characters. A substring is a portion of a string that contains a sequence of characters from the original string. A substring can be obtained in Go by using the slicing syntax on a string value. In this article we are going to learn different methods to get the index of a substring in a string using golang programming. Method 1: Using a For Loop In this method, the function that we ...

Read More

Golang Program to merge two integer arrays without using library function

Akhil Sharma
Akhil Sharma
Updated on 16-Feb-2023 840 Views

An array in go language is defined as the data structure that is used to store elements in contiguous memory locations. Arrays allow us to search and store elements at constant time. arrays use index to store elements which starts from 0 and goes to n – 1, where n is the length of the array. Here we will use two methods in the first method we will implement the logic in the main section of the program while in the second one we will use an external function. Method 1:Using For Loops In The Main Here we will use ...

Read More

Golang Program to convert int type variables to long

Akhil Sharma
Akhil Sharma
Updated on 16-Feb-2023 2K+ Views

In go language a long type variable is not a separate data type but it is an extension made from the integer data type to store even larger types of integers. The main difference between an int data type and long data type is that int data type is 32 bits whereas long data type is 64 bits. Syntax func typeOf (x interface{}) The typeOf() function is used to get the type of any variable. This function is present in reflect package and it takes the variable whose type is to be determined as an argument. The function then ...

Read More

Golang Program to cyclically permutes the elements of the array

Akhil Sharma
Akhil Sharma
Updated on 16-Feb-2023 255 Views

Cyclically means that in every cycle we wish to move the array elements by one position till we get the original array again. Cyclic permutation can be useful in various matrix manipulation and linear algebra operations. In this article, we are going to see different examples to permute the elements of the array cyclically 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 to which we wish to add the values followed by the ...

Read More

Golang Program to check a given number is finite or not

Akhil Sharma
Akhil Sharma
Updated on 16-Feb-2023 1K+ Views

In this article we will write a go language program to check if a given number is finite or not. The program uses IsInf() and IsNaN() library functions in order to check whether numbers are finite or not. Syntax func IsInf(f float64, sign int) bool IsInf() function is present in the math package. This function takes two arguments one is the floating point number that we wish to check and the other is the sign. The sign is an integer which can be greater than, lesser than, or equal to zero. If the sign is greater than zero then ...

Read More

Golang Program to delete an item from the array without using the library function

Akhil Sharma
Akhil Sharma
Updated on 16-Feb-2023 677 Views

An array in go language is defined as the data structure that is used to store elements in contiguous memory locations. Arrays allow us to search and store elements at constant time. arrays use index to store elements which starts from 0 and goes to n – 1, where n is the length of the array. Method 1: Using An External User-Defined Function The following method, illustrates how we can remove a particular integer element from the array of integers using an external function. Algorithm Step 1 − Import the fmt package. Step 2 − Defining a function named ...

Read More
Showing 16681–16690 of 21,090 articles
Advertisements