Learn Golang

Go Structures

Go Structures are a user-defined data type available in Golang, which allows you to combine different values types (including structures) into one type, its similar to Classes in other object-oriented programming languages, Assume you want to keep track of the articles in a blog. You might want to track the following attributes of each article − Title Body Category Author Defining a Structure To define a structure, you must use type and struct statements. The struct statement ...

Go Range

The range keyword is used to iterate over elements of an slice, array, map or channel. range over Arrays and Slices Use one variable to get the index of an element. Use two varaibles to get both index and the value of an element. range over Maps Use one variable to get the key of an element. Use two varaibles to get both key and the value of an element. range over Channels Use one variable to get the value of an element. How to use range ? ...

Go Strings

Strings, which are widely used in Go programming, are a readonly slice of bytes. In the Go programming language, strings are slices. Go standard library provides many libraries to work with strings. strings regexp unicode Creating Strings in Go To create a string you use douple quotes "" not a single quote, however you can use backtick ` for raw strings \n will be printed as \n not as a newline in raw strings, in the following snippet we use double qoutes: welco...