Mastering Go Notes
If you have to check godoc offline, you could install gdoc
go get golang.org/x/tools/cmd/godoc
and then rungodoc -http :8001
in termilal.Go consider the
main()
function the entry point to the application and begins the execution of the applicaiton with the code found in themain()
function of themain
package.Everything that begins with a lowercase letter is considered private and is accessible in the current package only.
If no initial value is given to a variable, the Go compiler will automatically initialize that variable to the zero value of its data type.
The
var
keyword is mostly used for declaring global or local variables without an initial value. Since every statement that exists outside of the code of a function must begin with a keywoprd such asfunc
,const
orvar
, you can’t use short assignment statement:=
outside of the function.The
os.Args
string
slice is properly initialized by Go and is available to the program when referenced.