Skip to content

Instantly share code, notes, and snippets.

@jafstar
Created June 19, 2012 03:09
Show Gist options
  • Save jafstar/2952078 to your computer and use it in GitHub Desktop.
Save jafstar/2952078 to your computer and use it in GitHub Desktop.
Go Cheat Sheet
/** Taken From: http://golang.org/cmd/go/ **/
//COMMANDS
build compile packages and dependencies
clean remove object files
doc run godoc on package sources
env print Go environment information
fix run go tool fix on packages
fmt run gofmt on package sources
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 run go tool vet on packages
//BUILD
go build [-o output] [build flags] [packages]
//REMOVE
go clean [-i] [-r] [-n] [-x] [packages]
//DOCUMENTATION
go doc [-n] [-x] [packages]
//PRINT ENVIRONMENTAL VARS
go env [var ...]
//DOWNLOAD AND INSTALL PACKAGES
go get [-a] [-d] [-fix] [-n] [-p n] [-u] [-v] [-x] [packages]
//FLAGS
-a
force rebuilding of packages that are already up-to-date.
-n
print the commands but do not run them.
-p n
the number of builds that can be run in parallel.
The default is the number of CPUs available.
-v
print the names of packages as they are compiled.
-work
print the name of the temporary work directory and
do not delete it when exiting.
-x
print the commands.
-compiler name
name of compiler to use, as in runtime.Compiler (gccgo or gc)
-gccgoflags 'arg list'
arguments to pass on each gccgo compiler/linker invocation
-gcflags 'arg list'
arguments to pass on each 5g, 6g, or 8g compiler invocation
-ldflags 'flag list'
arguments to pass on each 5l, 6l, or 8l linker invocation
-tags 'tag list'
a list of build tags to consider satisfied during the build.
See the documentation for the go/build package for
more information about build tags.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment