Golang vs Python: The Ultimate Battle in DevOps

In the world of DevOps, two programming languages are often pitted against each other: Golang and Python.

Read More

How to Create a Password Generator in Golang

Introduction In today’s digital age, password security is more important than ever before.

Read More

How to Convert Time to String in Golang

If you need to convert Time to a String in Go, then you can do one of the following:

Read More

How to Perform a Deep Copy in Golang

To perform a Deep Copy in Go, you can use a struct type as follows:

Read More

How to Return Lambda Functions in Golang

Go doesn’t typically have Lambda Expressions, but synonymous to Lambdas, or Closures if Anonymous Functions for Go.

Read More

How to Create an Empty Slice in Golang

If you would like to create an empty slice in Go, then you can do the following:

Read More

[Solved] dial tcp: lookup proxy.golang.org: i/o timeout

If you get a timeout when trying to install go dependencies, the error may look something like this:

Read More

How to Execute Linux Commands in Golang

If you want to execute linux commands in Golang, then you can use exec.

Read More

How to Check for Prime Numbers using Golang

If you need to check for Prime Numbers in Golang, then you can use the following method:

Read More

How to Raise a Number to a Power in Golang

If you need to raise a number to a power in Golang, then you can use the math.

Read More

How to Calculate the Sum of the Numbers in the Nth row of a Triangle in Golang

The challenge Given the triangle of consecutive odd numbers: 1 3 5 7 9 11 13 15 17 19 21 23 25 27 29 .

Read More

How to SHA256 a String in Golang

If you need to SHA256 a String in Go, then you can use the crypto/sha256 package.

Read More

How to Base64 Encode/Decode in Golang

Go ships with an encoding/base64 package that allows for encode and decoding of Base64 strings.

Read More

How to perform Array Element Parity in Golang

The challenge You will be given an array of integers whose elements have both a negative and a positive value, except for one integer that is either only negative or only positive.

Read More

Irreducible Sum of Rationals in Golang

The challenge You will have a list of rationals in the form:

Read More

Calculating Cartesian Neighbors Distance in Golang

The challenge We have been searching for all the neighboring points in a Cartesian coordinate system.

Read More

How to Calculate Dominant Primes in Golang

The challenge The prime number sequence starts with: 2,3,5,7,11,13,17,19.... Notice that 2 is in position one.

Read More

How to Solve Simple Square Numbers in Golang

The challenge In this challenge, you will be given a number n (n > 0) and your task will be to return the smallest square number N (N > 0) such that n + N is also a perfect square.

Read More

How to perform Function Iteration in Golang

The challenge The purpose of this challenge is to write a higher-order function returning a new function that iterates on a specified function a given number of times.

Read More

How to Find the Sum of Prime-Indexed Elements in Go

The challenge You will be given an integer array and your task is to return the sum of elements occupying prime-numbered indices.

Read More

Calculate the Most Frequent Weekdays in Go

The challenge What is your favourite day of the week? Check if it’s the most frequent day of the week in the year.

Read More

Return Index of Matching Closing Bracket in Go

The challenge In this challenge, you will be given a string with brackets and an index of an opening bracket and your task will be to return the index of the matching closing bracket.

Read More

How to Sum the Average for NBA Players in Golang

The challenge Write a function, called sumPPG, that takes two NBA player objects/struct/Hash/Dict/Class and sums their PPG

Read More

How to Compute a Cube as Sums in Golang

The challenge You will be given a number n (where n >= 1) and your task is to find n consecutive odd numbers whose sum is exactly the cube of n.

Read More

How to create a Coordinates Validator in Golang

The challenge You need to create a function that will validate if given parameters are valid geographical coordinates.

Read More

How to Validate ISBN-10 numbers in Golang

The challenge ISBN-10 identifiers are ten digits long. The first nine characters are digits 0-9.

Read More

How to Replace Noun Phrases with Pronouns in Golang

The challenge A Noun Phrase is a phrase that can be replaced by a pronoun [he/she/it].

Read More

Maximum Positive Integer Rotations in Golang

The challenge Write function MaxRot(n) which given a positive integer n returns the maximum number you got doing rotations similar to the above example.

Read More

How to Find the Sum of Angles in Golang

The challenge Find the total sum of internal angles (in degrees) in an n-sided simple polygon.

Read More

How to Stop a Goroutine in Golang

It’s possible to stop a Goroutine by sending a value into it via a signal channel:

Read More

Highest Rank Number in an Array in Golang

The challenge Complete the method which returns the number which is most frequent in the given input array.

Read More

How to Reverse Sort Integers in Go

The challenge The two oldest ages function/method needs to be completed.

Read More

How to Reimplement the Unix Uniq Command in Golang

The challenge Implement a function which behaves like the uniq command in UNIX.

Read More

How to check if a string is empty in Go

If you need to check if a string is empty in Go, then there are two possible ways to immediately verify this:

Read More

How to read a file line by line in Go

If you need to read a file line by line in Go, then you can use the bufio package as follows:

Read More

Floating-point Approximation in Golang

The challenge Consider the function f: x -> sqrt(1 + x) - 1 at x = 1e-15.

Read More

All the Ways to Divide an Array in Two in Golang

The challenge Write a function partlist that gives all the ways to divide an array of at least two elements into two non-empty parts.

Read More

How to check if a file exists in Go

If you need to check if a file exists using Go, then you can use one of the following methods, depending on the version of Go you may be using.

Read More

How to convert a string value to an int in Go

If you need to convert a string to an int in Go, then you should use the strconv.

Read More

How to convert an int value to string in Go

If you need to convert an int to a string in Go, then you should use the strconv.

Read More

How to Efficiently Concatenate Strings in Go

If you are using a version of Go >= 1.10, then you should be using the newer strings.

Read More

How to check if a map contains a key in Go

If you have a map in Go and want to only perform an action if it contains a certain key, then you can do so easily:

Read More

How to Loop Forever in Golang

If you need to loop forever, or infinitely, in your Go code, then you have 2 options:

Read More

Understanding For Loops in Golang

In Golang a for loop is a way to loop through an iterable.

Read More

[Solved] go mod init: modules disabled by GO111MODULE=off

You’ve probably just tried to initialise a new Go module, and received the following error:

Read More

How to UpperCase the start of each Word in a String in Golang

The challenge The task is to take a string of lower-cased words and convert the sentence to upper-case the first letter/character of each word

Read More

How to Find the Smallest Integer in the Array in Golang

The challenge Given an array of integers your solution should find the smallest integer.

Read More

Forming Unique Array Combinations in Golang

The challenge You are given an array of arrays and your task will be to return the number of unique arrays that can be formed by picking exactly one element from each subarray.

Read More

How to Sum all the Integers in a String in Golang

The challenge Implement a function that calculates the sum of the integers inside a string.

Read More

How to Reverse a String in Golang

The challenge Complete the solution so that it reverses the string passed into it.

Read More

How to Find the Last Digit of a Huge Number in Golang

The challenge For a given list [x1, x2, x3, ..., xn] compute the last (decimal) digit of x1 ^ (x2 ^ (x3 ^ (.

Read More

How to Circularly Sort an Array in Golang

The challenge An array is circularly sorted if the elements are sorted in ascending order but displaced, or rotated, by any number of steps.

Read More

How to Alternate String Casing in Golang

The challenge Write a function toWeirdCase (weirdcase in Ruby) that accepts a string, and returns the same string with all even indexed characters in each word uppercased, and all odd indexed characters in each word lowercased.

Read More

Roman Numerals Decoder in Golang

The challenge Create a function that takes a Roman numeral as its argument and returns its value as a numeric decimal integer.

Read More

How to Subtract from Time in Golang

The challenge Clock shows h hours, m minutes and s seconds after midnight.

Read More

Bit Counting in Golang

The challenge Write a function that takes an integer as input, and returns the number of bits that are equal to one in the binary representation of that number.

Read More

How to Find Next Higher Number with Same Bits in Golang

The challenge Find the next higher number (int) with same ‘1’- Bits.

Read More

How to Find the First Non-Repeating Character in Golang

The challenge Write a function named first_non_repeating_letter that takes a string input, and returns the first character that is not repeated anywhere in the string.

Read More

How to Find the Last Fibonacci Digit in Golang

The challenge Return the last digit of the nth element in the Fibonacci sequence (starting with 1,1, to be extra clear, not with 0,1 or other numbers).

Read More

How to Validate an IP Address in Golang

The challenge Write an algorithm that will identify valid IPv4 addresses in dot-decimal format.

Read More

Formatting Strings with Fmt in Golang

Fmt provides printing to standard output (usually the console) and formatting of strings capabilities.

Read More

How to Read from Standard Input in Golang

Reading from “standard input” is really useful if you are making a command-line application and require user input.

Read More

How to Install Golang on WSL/WSL2

If you need to install Golang on WSL under Windows 10 or higher, you can follow these few steps.

Read More

How to Repeat by String Index in Golang

The challenge Create a function that repeats each character by the amount of it’s index value of the original string.

Read More

Calculate the Third Angle of a Triangle in Go

The challenge You are given two interior angles (in degrees) of a triangle.

Read More

How to Detect if Numbers are in Order in Golang

The challenge In this challenge, your function receives an array of integers as input.

Read More

Alternate Capitalization in Golang

The challenge Given a string, capitalize the letters that occupy even indexes and odd indexes separately, and return as shown below.

Read More

Check if a String is Uppercase in Golang

The challenge Create a method IsUpperCase to see whether the string is ALL CAPS.

Read More

How to UpperCase a String in Golang

In Go, there are multiple ways to make a string UpperCase, each of them are by using the strings package.

Read More

Return the Shortest Words in Golang

The challenge Given a string of words, return the length of the shortest word(s).

Read More

Creating a Multiplication Table for a Number in Golang

The challenge Your goal is to return multiplication table for number that is always an integer from 1 to 10.

Read More

How to Remove Duplicates in an Array in Golang

The challenge Remove the left-most duplicates from a list of integers and return the result.

Read More

How to Dry Potatoes in Golang

The challenge All we eat is water and dry matter.

Read More

How to Reverse or Rotate in Golang

The challenge The input is a string str of digits. Cut the string into chunks (a chunk here is a substring of the initial string) of size sz (ignore the last chunk if its size is less than sz).

Read More

Get which Quarter of the Year in Golang

The challenge Given a month as an integer from 1 to 12, return to which quarter of the year it belongs as an integer number.

Read More

Introducing Variables in Golang

Golang comes with a decent offering around variables that you can use to store, retrieve and manipulate information.

Read More

Golang cannot convert (type string) to type int

Every language has it’s ways of converting data types. One of the most common data types to convert between is that of strings (string) and integers (int).

Read More

Learn Golang as a Python Developer

Learning Go or Golang as a Python developer, programmer or software engineer is easier than you think.

Read More