Server Side Programming Articles

Page 1667 of 2109

Golang program to convert vector to a list

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

In Golang, a vector is referred to as an array or a slice. Slice is a dynamic array whose size can be changed whereas a linked list data structure is one type of list, where each node has a value and is pointing to the next element. We will use two examples in this program to convert vector to a list. In the very first example a built-in copy function will be used and in the second example we will iterate the slice in the reverse order to obtain the output. Method 1: Using Copy Function In this method, we ...

Read More

Golang program to call one constructor from another

Akhil Sharma
Akhil Sharma
Updated on 20-Feb-2023 955 Views

In Go programming language, a constructor is a specific kind of function used to initialize an object's state when it is initially formed. It is used to initialize variables and provide data for the objects. We will execute this program using two methods and we will use struct in both of these examples with anonymous struct in the second example. Let’s see through these examples to understand how the program is executed. Method 1: Using a function that returns a desired type In this method, to construct a new Child struct, the NewChildWithAge function runs the NewChildfunction, sets the age, ...

Read More

Golang Program to Check Whether the Given String is Pangram

Akhil Sharma
Akhil Sharma
Updated on 20-Feb-2023 679 Views

In this article, we will understand different golang examples to check whether a given string is pangram. A statement known as a pangram uses each letter of the alphabet at least once. A pangram is a string in the programming language Golang that contains every letter of the alphabet, regardless of case. Syntax strings.ToLower(str) Using strings in Go (golang), you can change a string's case to lowercase. The strings package's ToLower() function. 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 ...

Read More

Golang program to find the duplicate characters in the string

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

In golang, identifying characters that appear more than once in a string is the first step in finding duplicate characters. To accomplish this, iterate through the string while keeping track of the characters that have already been encountered. Then, before adding a character, determine if it is already in the set of characters that have already been encountered. A character is a duplication if it already exists in the set. Let’s see its execution. Method 1: Using map and a for loop In this method, the program uses a map to keep track of the number of times each character ...

Read More

Golang program to remove all whitespaces from a string

Akhil Sharma
Akhil Sharma
Updated on 20-Feb-2023 6K+ Views

When we remove whitespaces from a string it means removing blank spaces, tabs, and other white space characters, including newline characters. This can be helpful for parsing user input or working with data in a particular format, among other instances where we wish to clean up or standardize a string before processing it further. There are various ways to eliminate whitespace from a string. A few examples include: Using the TrimSpace function, whitespace characters at the beginning and end of a string are eliminated. Using the Replace function to replace any whitespace in the string with a string that is ...

Read More

Golang program to show use of super keyword in class

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

In golang, the "super" term doesn't exist in Go. The "super" keyword is used in object-oriented programming languages to denote the parent class or the class that is being inherited from. It is often used to access parent class methods or properties that the child class has modified. In this article, we will see how to use super keyword in the class with different examples. Method 1: Using child struct and parent struct In this Method, we will learn how to use super keyword in class using child struct and parent struct. Here, a Parent struct is embedded in the ...

Read More

Golang program to print first letter of each word using regex

Akhil Sharma
Akhil Sharma
Updated on 20-Feb-2023 666 Views

A string of characters known as a regular expression (regex or regexp) creates a search pattern. Regular expressions are frequently employed to carry out string matching, sometimes known as "find and replace, " or pattern matching with strings. Input validation, parsing, and other tasks are also possible with them. Regular expressions use special characters and metacharacters to specify the pattern to be matched, and their syntax differs widely between computer languages. Let’s see different Golang examples to get a clear view of the concept. Method 1: Using regex.MustCompile() function In this example, we will see how to print first ...

Read More

Golang program to remove leading zeros

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

Removing any zeros that appear at the start of a number or string is referred to as "removing leading zeros" in Golang. Leading zeroes are frequently included for formatting or alignment needs, although they don't convey any significant information. They can be eliminated to improve the number's or string's usability and human-readableness. It's important to keep in mind that leading zeroes can occasionally be crucial for specific applications, such as some financial or scientific ones. Let’s see through this program to get a clear understanding of the concept. In this program we will learn how to remove leading zeros using ...

Read More

Golang program to compute all the permutations of the string

Akhil Sharma
Akhil Sharma
Updated on 20-Feb-2023 940 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 permutation of a string is a distinct string with the same characters but a different ordering of the characters. For instance, the words "abcd" and "dabc" are combinations of one another. Here, in this program we will explore method to find permutation of string and print the output on the console using print statement in Golang. Syntax func append(slice, element_1, element_2…, element_N) []T The append function is used ...

Read More

Golang program to create a multi-line string using '%Q

Akhil Sharma
Akhil Sharma
Updated on 20-Feb-2023 845 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. The multi-line will be printed using backticks and the output will be printed on the console using fmt package. Let’s see different examples to get a clear understanding of the concept. The fmt employs the verb %q. To print the string in a format that can be securely included inside double-quoted string literals, use the printf function. This guarantees that any special characters, such as newlines, in the string will ...

Read More
Showing 16661–16670 of 21,090 articles
Advertisements