For understanding whether two interface variables are equal or not, we first need to understand the internal representation of an interface. Like any other variable, an interface variable is represented by a…
Tag: golang
Basic HTTP Server Implementation Using Go (Golang)
Overview HTTP (Hypertext Transfer Protocol) is an application layer protocol and works in client-server mode. HTTP server is basically a program running on a machine. It listens and responds to HTTP requests…
Pass an Interface as an argument to a function in Go (Golang)
A function can accept an argument of an interface type. That interface type can be either Regular Interface Empty Interface Let’s see example for both of them one by one Regular Interface…
Understanding := symbol or short variable declaration in Go (Golang)
Go provides another way of declaring variables which is using the := operator. When := operator is used both var keyword and type info can be omitted. Below is the format for…
Scope of a variable in Go (Golang)
Scope of a Variable (Local and Global Variable) A variable declaration can be done at the package level or a function level or a block level. The scope of a variable defines…
Understanding var keyword in Go (Golang)
var keyword is a reserved keyword in golang which is used to declare variables in go .variables are declared using the var keyword but there are other ways of declaring a variable…
Fallthrough keyword in Switch Statement in Go (Golang)
fallthrough keyword is used in switch statement in golang. This keyword is used in switch case block. If the fallthrough keyword is present in the case block, then it will transfer control…
Create/Initialize/Declare map in Go (Golang)
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…
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…