Constants
Constants in Go are just that—constant.
can only be numbers, characters (runes), strings or booleans.
enumerated constants are created using the iota enumerator
type ByteSize float64const (_ = iota // ignore first value by assigning to blank identifierKB ByteSize = 1 << (10 * iota)MBGBTBPBEBZBYB)
Variables
var (home = os.Getenv("HOME")user = os.Getenv("USER")gopath = os.Getenv("GOPATH"))
The init function
Each source file can define its own niladic init function, finally.
(each file can have multiple init functions)
func init() {if user == "" {log.Fatal("$USER not set")}if home == "" {home = "/home/" + user}if gopath == "" {gopath = home + "/go"}// gopath may be overridden by --gopath flag on command line.flag.StringVar(&gopath, "gopath", gopath, "override default GOPATH")}
