go command [arguments]

The commands are:

    build       compile packages and dependencies
    clean       remove object files and cached files
    doc         show documentation for package or symbol
    env         print Go environment information
    bug         start a bug report
    fix         update packages to use new APIs
    fmt         gofmt (reformat) package sources
    generate    generate Go files by processing source
    get         download and install packages and dependencies
    install     compile and install packages and dependencies
    list        list packages
    run         compile and run Go program
    test        test packages
    tool        run specified go tool
    version     print Go version
    vet         report likely mistakes in packages

Environment Variables

It is not necessary to set the GOROOT environment variable if the go executable is installed in a standard location.

The GOPATH environment variable is a list of directories outside of GOROOT used by the go executable to find source code and binaries.

Building Go

go run and go test compiles files if the source are newer than the binary or if the binary is missing.

Running Go

Go Packages

Use "package" at the top of a file to declare a package. Use "import" to access identifiers in the package from another file.

Only capitalized identifiers are visible outside the package.

Testing Go

A test function identifier starts with "Test" and takes a single argument of type "testing.T".

Unless otherwise stated, the content of this page is licensed under Creative Commons Attribution-ShareAlike 3.0 License