# Go

## 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. So MaxRot is such as: MaxRot(56789) should… Read More »Maximum Positive Integer Rotations in Golang

## 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. N will be greater than 2. The solution in… Read More »How to Find the Sum of Angles in Golang

## How to Stop a Goroutine in Golang

It’s possible to stop a Goroutine by sending a value into it via a signal channel: As an alternative, you could also use a WaitGroup… Read More »How to Stop a Goroutine in Golang

## 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. If there is a tie for the… Read More »Highest Rank Number in an Array in Golang

## How to Reverse Sort Integers in Go

The challenge The two oldest ages function/method needs to be completed. It should take an array of numbers as its argument and return the two highest… Read More »How to Reverse Sort Integers in Go

## How to Reimplement the Unix Uniq Command in Golang

The challenge Implement a function which behaves like the uniq command in UNIX. It takes as input a sequence and returns a sequence in which… Read More »How to Reimplement the Unix Uniq Command in Golang

## 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: Option 1 –… Read More »How to check if a string is empty in Go

## 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: Just note that the… Read More »How to read a file line by line in Go

## Floating-point Approximation in Golang

The challenge Consider the function f: x -> sqrt(1 + x) – 1 at x = 1e-15. We get: f(x) = 4.44089209850062616e-16 This function involves the subtraction of… Read More »Floating-point Approximation in Golang

## 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. Each two non… Read More »All the Ways to Divide an Array in Two in Golang

## 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… Read More »How to check if a file exists in Go

## 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.Atoi function: Learn how to convert an int… Read More »How to convert a string value to an int in Go

## 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.Itoa function: Learn how to convert a string… Read More »How to convert an int value to string in Go

## 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.Builder pattern as follows: For older version, you… Read More »How to Efficiently Concatenate Strings in Go

## How to Loop Forever in Golang

If you need to loop forever, or infinitely, in your Go code, then you have 2 options: Option 1: Option 2: Just remember that you… Read More »How to Loop Forever in Golang

## Understanding For Loops in Golang

In Golang a for loop is a way to loop through an iterable. The most basic For Loop A classic For Loop For Loop without… Read More »Understanding For Loops in Golang

## [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: go mod init: modules disabled by GO111MODULE=off; see ‘go help… Read More »[Solved] go mod init: modules disabled by GO111MODULE=off

## 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. For example: Given [34, 15, 88, 2] your solution will return 2 Given [34, -345,… Read More »How to Find the Smallest Integer in the Array in Golang

## 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… Read More »Forming Unique Array Combinations in Golang

## 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. For example, in the string “The30quick20brown10f0x1203jumps914ov3r1349the102l4zy dog”, the sum of the… Read More »How to Sum all the Integers in a String in Golang

## How to Reverse a String in Golang

The challenge Complete the solution so that it reverses the string passed into it. The solution in Golang Option 1: Option 2: Option 3: Test… Read More »How to Reverse a String in Golang

## 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. Complete the function/method… Read More »How to Circularly Sort an Array in Golang