Templates in Golang

In this post, we will see templates and their usages in the Go programming language. What are templates? Templates are a common view through which we can pass data to make that view meaningful. It can be customized in any way to get any output possible. Template packages Templating in Go comes with two packages […]

Templates in Golang Read More »

Using JSON with Golang

In this post, we are going to see how to use JSON in the Go programming language. What is JSON? JSON is short for JavaScript Object Notation, a widely-used data interchange format. JSON is an extremely useful data format and is used almost everywhere today. Data-types supported in JSON and Go Below are some data-types

Using JSON with Golang Read More »

Slices in Golang

Slices are resizable arrays that provide huge flexibility when working with it. In this post, we will see how to use slices in Golang. Declaration of a slice A slice is declared just like an array but without mentioning its size. Difference between slices and arrays Arrays, after declared of some size, cannot be resized,

Slices in Golang Read More »

Structs in Golang

Structs are a way to structure and use data. It allows us to group data. In this article, we will see how to declare and use it. Defining a Struct in Go To use a struct we declare the type of struct we are going to use. The code below shows how to define a

Structs in Golang Read More »

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 »