Go Noteables
Go
Go, the prodigal brainchild of various engineers, community enthusiasts (Gophers) and brilliant language/compiler developers, is perhaps Google’s best contribution to the Computer Science field.
Important Packages
os - contains the go code available for interacting with the operating system hosting a go executable
- os.Args - a slice of strings that represent the command line arguments passed into a Go application’s runtime environment
Lingo
slice - a dynamically sized sequence of array elements. Individual elements can be accessed as
mySlice[i]
…chunks can be accessed as
mySlice[m:n]
…and the length is reported with
len(mySlice)
Conventions
zero values - any variable that’s not defined in its declaration takes what’s called a “zero value”
- string –> “” (empty string)
- numeric types –> 0
:= - the “short variable declaration” is the operator used in a statement to declare one or more variables and give them appropriate types based on the initializer value
x := 2 // initializes x to 2
Updating Go
$ sudo rm -rf /usr/local/go
# Download latest tar from distribution (https://golang.org/dl/)
$ sudo tar -C /usr/local -xzf <path-to-tarball>
# Edit GOROOT, GOPATH and PATH
$ echo $PATH | grep "/usr/local/go/bin"