Member-only story
Advanced Go Coding — Go command and its flags
Unleashing the Power of Go Command-Line Tools
In the Go ecosystem that makes our development simple and efficient, the command-line commands play big roles. They can be classified into three: Execution commands, such as, run
, test
, build
, generate
, debug
, etc.; Tool commands, such as, tool
, fmt
, vet
, clean
, etc.; Environment commands, such as, work
, mod
, env
, install
, etc. For their functions to be fully enjoyed, we need to understand the various commands and environment variables.
Execution Commands and Flags
The four execution-related commands compose the Go code main workflow: build
for code compilation; run
for code execution; test
for executing tests; debug
for debugging.
go build
go build
is designed for building Go projects and generating binary executable files.
There are three common flags. -o
specifies output file name, -v & -x
displays the…