Overview Maps are golang builtin datatype similar to the hash table which maps a key to a value. Below is the format for a map: Both key_type and value_type can be of…
Tag: go
Format specifier for boolean or print boolean in Go (Golang)
Different format specifiers can be used to print a boolean in either bool or string. %t can be used to print in the boolean form %v will print the default string. “true”…
Allowed key and value types for a map in Go (Golang)
Maps are golang builtin datatype similar to the hash table which maps a key to a value. . Below is the format for a map: Both key_type and value_type can be of…
Update a key in the map in Go (Golang)
When trying to add a key to the map which already exists, the new value will override the old value. This is analogous to updating a key in the map. Let’s see…
Iterate over a string in Go (Golang)
In Golang string is a sequence of bytes. A string literal actually represents a UTF-8 sequence of bytes. In UTF-8, ASCII characters are single-byte corresponding to the first 128 Unicode characters. All other…
Length of string in Go (Golang)
In Golang string is a sequence of bytes. A string literal actually represents a UTF-8 sequence of bytes. In UTF-8, ASCII characters are single-byte corresponding to the first 128 Unicode characters. All other…
Declare/Initialize/Create an array or slice in Go (Golang)
Overview Similar to any other programming language, golang also has an array data structure. But in go, arrays behave little differently than other languages and also we have something called slice in…
Pointer Receiver for a method in Go (Golang)
To better understand pointer receiver we first have to understand the value receiver for a method. Methods on Value Receiver Let’s see an example of a value receiver Output Notice that the…
Method in Go (Golang)
This is the chapter 20 of the golang comprehensive tutorial series. Refer to this link for other chapters of the series – Golang Comprehensive Tutorial Series Next Tutorial – InterfacePrevious Tutorial – Maps Now let’s check…
Method Chaining in Go (Golang)
For method chaining to be possible, the methods in the chain should return the receiver. Returning the receiver for the last method in the chain is optional. Let’s see an example of…