Go Tool: Difference between revisions
(→vet) |
(→env) |
||
Line 78: | Line 78: | ||
==<tt>env</tt>== | ==<tt>env</tt>== | ||
{{Internal|go env#Overview|<tt>go env</tt>}} | |||
< | |||
go env | |||
</ | |||
==<tt>get</tt>== | ==<tt>get</tt>== | ||
The <code>get</code> command retrieve and update packages. | The <code>get</code> command retrieve and update packages. |
Revision as of 22:01, 27 October 2023
External
Internal
Overview
go
is a command line tool with multiple uses: package manager, build tool and test driver. go
manage packages in workspaces, query metadata about packages, print documentation, build, format, download, test, etc.
Commands
Help
go help <command>
go help build
build
install
run
The run
command compiles the specified packages or files by delegating to go build
and then runs the executable. There must be a main
for an executable to be generated.
cd $PROJECT_DIR
go run ./src/main/main.go some-arg-1 some-arg-2
The first argument that does not end in .go
is assumed to be the beginning of the list of command line arguments of the executable.
The shared flags described here apply:
clean
The shared flags described here apply:
-cache
Clean the build cache:
go clean -cache
-fuzzcache
Clean the fuzz cache:
go clean -fuzzcache
doc
The doc
command prints documentation for a package or a package member:
go doc time
go doc time.Since
Deplete: doc
fmt
The fmt
("format") command formats source code files.
Deplete: fmt
get
The get
command downloads packages and installs them. The shared flags described here apply:
Deplete: get
list
The list
command lists all installed packages. The shared flags described here apply:
test
The test
command runs tests. The shared flags described here apply:
For more details, see:
env
get
The get
command retrieve and update packages.
TODO Addison-Wesley The Go Programming Language Section 10.7.2
mod
vet
Deplete: vet
version
Deplete version