Maps in Golang

Maps are one of the most useful data structures. It can store in key-value pairs and doesn’t allow for duplicate keys. Now, we will learn how the Go programming language implements maps. What is a map? A map is a key-value pair storage container. It offers fast and efficient lookups. And it doesn’t allow duplicate […]

Maps in Golang Read More »

Booleans in Golang

In this post, we will discuss boolean values and operators in Golang. Boolean values in Go Boolean values are those which can be assigned true or false and has the type bool with it. In the code above “bVal” is not initialized and thus has a zero-value. The zero-value for a boolean is false. Boolean

Booleans in Golang Read More »

Strings in Golang

Strings are essential in every programming language. Go is no different here. We will see how to initialize and use those strings. Initializing Strings in Golang We can initialize strings just like any other data-type. String concatenation can be done effortlessly. Accessing by index Strings in Go can be accessed just like an array or

Strings in Golang Read More »

Arrays in Golang

Arrays are consecutive storage of the same data-type. In this post, we will see how arrays work in Golang. Declaration of an Array To declare an array in Go we first give its name, then size, then type as shown below. Initialization of an Array Let’s see how to initialize an array. If we don’t

Arrays in Golang Read More »

Complex Numbers in Golang

There are two complex types in Go. The complex64 and the complex128. Initializing Complex Numbers Initializing complex numbers is really easy. You can use the constructor or the initialization syntax as well. Parts of a Complex Number There are two parts of a complex number. The real and imaginary part. We use functions to get

Complex Numbers in Golang Read More »

Floating-Point Numbers in Golang

Go supports the IEEE-754 32-bit and 64-bit floating-point numbers extensively. Let’s see how to use it. Loss of Precision with Floating Point Numbers Loss of precision will occur when a 64-bit floating-point number is converted to 32-bit float. Complex numbers Floating-point numbers are used in complex numbers as well. The real and imaginary parts are

Floating-Point Numbers in Golang Read More »

Integers in Golang

Go supports integer data types extensively. Now, we will see what are those. Signed integers in Go Signed integer types supported by Go is shown below. int8 (8-bit signed integer whose range is -128 to 127) int16 (16-bit signed integer whose range is -32768 to 32767) int32 (32-bit signed integer whose range is -2147483648 to

Integers in Golang Read More »

Functions in Golang

Functions are essential in any programming language. They help structure the code and make routine tasks easier to do. Go has support for “First Class Functions” which means functions in Go can be assigned to variables, passed as an argument and can be returned from another function. Declaring and calling functions To declare a function

Functions in Golang Read More »

Command Line arguments in Golang

Let’s start writing some programs in Go that will allow us to pass command-line arguments when running the program. It is really easy and allows us to pass custom arguments when running a Go program. We will create our custom arguments as well. Working with command-line arguments How to pass the arguments? Simply put those

Command Line arguments in Golang Read More »