Go 101 articles are mainly focus on syntaxes and semantics in Go. There are some other Go related knowledges are not covered in Go 101. The remaining of the current article will make simple introductions for those knowledges and provide some web links for readers to digg more on them.
go testcommand to run tests and benchmarks. Test source file names must end with
_test.go. The official Go SDK also supports profiling Go programs. Please read the following articles for more details.
gccgo is another Go compiler maintained by Go design team.
It is mainly used to verify the correctness of the standard Go compiler (gc).
We can use the
-compiler=gccgo build option in several official Go SDK
commands to use the gccgo compiler instead of the gc compiler.
go run -compiler=gccgo main.go.
On Linux, we can also install the "gccgo" package to use the gccgo comppiler.
More build options are listed here.
All subcommands of the
go commands are also explained in that article.
Functions can be implemented with Go assembly language. Go assembly language is a cross-architectures (though not 100%) assembly language. Go assembly language is often used to implement some functions which are critical for Go program execution performances.
It is possible to use C++ libraries through cgo.
Please note that using cgo in code may make it is hard to maintain cross-platform compatibility of Go pprograms, and the calls between Go and C code are much less efficient than Go-Go and C-C calls.
GOARCHenviroments before running the
go buildcommand, we can build a Windows executable on a Linux machine, and vice versa. Please read the following articles for details.
We can use build constraints
to let compilers build source files selectively.
A build constraint is called called a build tag.
A build constraint can appear as a comment line like
// +build constraints
or appear as the suffix in the base name of a source file.
The standard Go compiler supports several
A directive appears as a comment line like
The most used compiler directive in practice may be the
We can make system calls by call the functions exported by the
syscall standard package.
Please beware that, different from other standard packages,
the functions in the
syscall standard package are operating system dependent.
go/* standard packages provide functionalities of
parsing Go source files, which are very useful to write custom Go tools.
go/types: The Go Type Checker
and package documentations for how to use these packages.
go build command in the official Go SDK supports several build modes.
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 outputted Go plugin files by using the plugin build mode.