Overview math/rand package of GO provides a Shuffle method that can be used to shuffle a string. This method pseudo-randomizes the order of elements using the default source. pseudo-randomizes means that for…
Tag: go
Pick a random character in string in Go (Golang)
Overview ‘mat/rand’ package of golang contains a Intn function that can be used to generate a pseudo-random number between [0,n). Bracket at the end means that n is exclusive. This function can…
Pick a random element in an array or slice in Go (Golang)
Overview ‘mat/rand’ package of golang contains a Intn function that can be used to generate a pseudo-random number between [0,n). Bracket at the end means that n is exclusive. This function can…
Generate a random password in Go (Golang)
Overview ‘math/rand’ package of golang contains an Intn function that can be used to generate a pseudo-random number between [0,n). The bracket at the end means that n is exclusive. This function…
Print/Output text in color in console
Note: If you are interested in learning Golang, then for that we have a golang comprehensive tutorial series. Do check it out – Golang Comprehensive Tutorial Series. Now let’s see the current tutorial….
Generate Random number in Go (Golang)
Overview Go provide a ‘math/rand’ package which has inbuilt support for generating pseudo-random numbers. This package defines methods which can be used to generate A pseudo-random number within the range from 0…
Max of two numbers in Go (Golang)
Overview math package of GO provides a Max method that can be used to get the maximum of two numbers. Below is the signature of the function. It takes input two float…
Min of two numbers in Go (Golang)
Overview math package of GO provides a Min method that can be used to get the minimum of two numbers. The Below is the signature of the function. It takes input two…
Check if a number is negative or positive in Go (Golang)
Overview math package of GO provides a Signbit method that can be used to check whether a given number is negative or positive. It returns true for a negative number It returns…
Calculate x^y – Pow() in Go (Golang)
Overview math package of GO provides a Pow method that can be used to calculate x to the power y. Below is the signature of the function. It takes input as two…