More Go Related Resources

Go 101 articles mainly focus on syntax and semantics in Go. There are some other Go related knowledges which are not covered in Go 101. The remaining of the current article will make simple introductions to those knowledges and provide some web links for readers to digg more on them.

Tests And Benchmarks

We can use go test command in the official SDK 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

gccgo is another Go compiler maintained by the 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. 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.

More build options are listed here. All go sub-commands are also explained in that article.

Go Assembly

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.

For more details, please follow the following links.

cgo

We can call C code from Go code, and vice versa, through the cgo mechanism. Please follow the following links for details.

It is possible to use C++ libraries through cgo by wrapping C++ libraries as C functions.

Please note that using cgo in code may make it is hard to maintain cross-platform compatibility of Go programs, and the calls between Go and C code are some less efficient than Go-Go and C-C calls.

Cross-Platform Compiling

The standard Go compiler supports cross-platform compiling. By setting the GOOS and GOARCH enviroments 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. In particular, since Go 1.11, the official Go SDK starts to support WebAssembly as a new kind of GOARCH. Please read this wiki article for details.

Build Constraints (Tags)

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.

Compiler Directives

The standard Go compiler supports several compiler directives. A directive appears as a comment line like //directive args. The most used compiler directive in practice may be the go:generate directive.

System Calls

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.

The go/* Standard Packages

The 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 documentations for how to use these packages.

More Build Modes

The go build command in the official Go SDK 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 both github and gitlab. 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.

Support Go 101 by playing Tapir's games. Cryptocurrency donations are also welcome:
Bitcoin: 1xucQbv5jujFPPwhyg395ri5yV71hx9g9
Ethereum: 0x5dc4aa2c2bbfaadae373dadcfca11b3358912212