Articles on Trending Technologies

Technical articles with clear explanations and examples

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 942 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 847 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

Golang program to splitting into number of substrings

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

In the Go programming language, 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.. strings. Split() can be used in Go (Golang) to divide a string into substrings. The first input to the function is the string to be split, and the second argument is the delimiter that will be used to separate the substrings. A slice of strings containing the substrings is the result of the function. There are other ways to split a ...

Read More

Golang Program to Check if a string is a valid shuffle of two distinct strings

Akhil Sharma
Akhil Sharma
Updated on 20-Feb-2023 296 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 will learn how to check if a string is a valid shuffle of two strings using different set of examples. The output will be a Boolean value printed on the console using fmt package. Method: Using a for loop with len method In this method, we will learn how to check if a string is valid shuffle of two distinct strings. This program defines a function ...

Read More

Golang program to replace the spaces of string with a specific character

Akhil Sharma
Akhil Sharma
Updated on 20-Feb-2023 2K+ 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 first and foremost approach used here is Replace() method which replaces the space with a specific character and many more methods can be applied to solve the problem. The modifies string will be the output printed on the console using fmt package. Method 1: Using strings.Replace() function In this method, the space character (" ") is replaced with the character "-" using the Replace() function. The function is instructed ...

Read More

Golang program to insert a string into another string

Akhil Sharma
Akhil Sharma
Updated on 20-Feb-2023 2K+ 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 one Example characters. A string is added to or positioned within a bigger string when it is "inserted" into another string. This might be accomplished by replacing a specific substring within the bigger string or at a certain position or index within the larger string. This is frequently used in programming when a string needs to be modified or altered in a particular way, for as by adding a prefix or suffix ...

Read More

Golang Program to divide a string in 'N' equal parts

Akhil Sharma
Akhil Sharma
Updated on 20-Feb-2023 1K+ 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 UniExample characters. When a string is divided into n equal pieces, n substrings of equal length are created. Using string splitting or string slicing techniques in programming languages, the substrings can be obtained. Let’s see the examples to understand the logic. Method 1: Using for loop and built-in append function In this method, a function called divideString is defined accepts two inputs, a string and an integer, and outputs a slice of ...

Read More
Showing 40431–40440 of 61,297 articles
Advertisements