Go Tool: Difference between revisions
(→get) |
(→get) |
||
(18 intermediate revisions by the same user not shown) | |||
Line 50: | Line 50: | ||
go clean -fuzzcache | go clean -fuzzcache | ||
</syntaxhighlight> | </syntaxhighlight> | ||
==<tt>link</tt>== | |||
{{Internal|go tool link#Overview|<tt>go tool link</tt>}} | |||
==<tt>doc</tt>== | ==<tt>doc</tt>== | ||
{{Internal|Go_doc#Overview|<tt>go doc</tt>}} | |||
< | |||
</ | |||
==<span id='fmt'></span><tt>fmt</tt> (<tt>gofmt</tt>)== | ==<span id='fmt'></span><tt>fmt</tt> (<tt>gofmt</tt>)== | ||
{{ | {{Internal|Go_fmt#Overview|<tt>go fmt</tt>}} | ||
< | ==<span id='Problems_with_get'></span><tt>get</tt>== | ||
{{Internal|Go get#Overview|<tt>go get</tt>}} | |||
</ | |||
==<tt>list</tt>== | ==<tt>list</tt>== | ||
{{Internal|Go_list#Overview|<tt>go list</tt>}} | |||
==<tt>test</tt>== | ==<tt>test</tt>== | ||
{{Internal|Go test Command|<tt>go test</code> Command}} | |||
==<tt>env</tt>== | ==<tt>env</tt>== | ||
{{Internal|go env#Overview|<tt>go env</tt>}} | {{Internal|go env#Overview|<tt>go env</tt>}} | ||
==<tt>mod</tt>== | ==<tt>mod</tt>== | ||
{{Internal|go mod#Overview|<tt>go mod</tt>}} | {{Internal|go mod#Overview|<tt>go mod</tt>}} |
Latest revision as of 08:07, 23 November 2024
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.
Is the above true though? The following command runs fine, where "example.com/experimental-go-module/cmd/gotest" is the package path of a "main" package inside of the "example.com/experimental-go-module" module. No argument ends in .go
, yet it works:
go run example.com/experimental-go-module/cmd/gotest
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
link
doc
fmt (gofmt)
get
list
test
env
mod
vet
Deplete: vet
version
Deplete version