go test
command in Go Toolchain to run tests and benchmarks. Test source file names must end with _test.go
. Go Toolchain also supports profiling Go programs. Please read the following articles for more details.
-compiler=gccgo
build option in several Go Toolchain commands to use the gccgo compiler instead of the gc compiler. For example, go run -compiler=gccgo main.go
. This option requires the gccgo program is installed. Once the gccgo program is installed, we can also use the gccgo
command directly to compile Go code.
go/*
Standard Packages
go/*
standard packages provide functionalities of parsing Go source files, which are very useful to write custom Go tools. Please read go/types
: The Go Type Checker and package documentation for how to use these packages.
syscall
standard package. Please beware that, different from other standard packages, the functions in the syscall
standard package are operating system dependent.
GOOS
and GOARCH
environments before running the go build
command, we can build a Windows executable on a Linux machine, and vice versa. Please read the following articles for details.
//go:DirectiveName args
. For examples, we can use the go:generate directive to generate code and use the go:embed directive (introduced in Go 1.16) to embed some data files in code.
// +build constraints
or appear as the suffix in the base name of a source file. Please note: the new //go:build
directive introduced in Go 1.17 will retire the old // +build
constraints lines eventually.
go build
command in Go Toolchain supports several build modes. Please run go help buildmode
to show the available build modes or read the explanations for -buildmode option instead. Except the default build mode, the most used build mode may be the plugin build mode. We can use the functions in the plugin
standard package to load and use the Go plugin files outputted by using the plugin build mode.
The Go 101 project is hosted on Github. Welcome to improve Go 101 articles by submitting corrections for all kinds of mistakes, such as typos, grammar errors, wording inaccuracies, description flaws, code bugs and broken links.
If you would like to learn some Go details and facts every serveral days, please follow Go 101's official Twitter account @zigo_101.
reflect
standard package.sync
standard package.sync/atomic
standard package.