Initializing variables in Go

Normal initialization

var myStr string = "mystring"
var myInt int = 10

If you don't explicitly initialize a variable with a value, it will get the zero value for it's type.

var myStr string // myvar == ""
var myInt string // myvar == 0

Short initialization

Short initialization is performed using the := operator. It can only be done within a function, and the type of the variable is inferred from the value assigned to it.

myStr := "mystring"
myInt := 10

Disclaimer

Ideas may still be sprouting

Notes in my digital garden are written primarily for my own reference and understanding. They may be unfinished, unorganized, outdated, and/or incorrect.