snippetbashTip
go — Manage Go source code. Some subcommands such as `build` have their own usage documentation. More inf
Viewed 0 times
commandsourceclimanagecodesomegosubcommands
Problem
How to use the
go command: Manage Go source code. Some subcommands such as build have their own usage documentation. More information: <https://pkg.go.dev/cmd/go>.Solution
go — Manage Go source code. Some subcommands such as build have their own usage documentation. More information: <https://pkg.go.dev/cmd/go>.Download and install a package, specified by its import path:
go get {{path/to/package}}Compile and run a source file (it has to contain a
main package):go run {{file}}.goCompile a source file into a named executable:
go build -o {{executable}} {{file}}.goCompile the package present in the current directory:
go buildExecute all test cases of the current package (files have to end with
_test.go):go testCompile and install the current package:
go installInitialize a new module in the current directory:
go mod init {{module_name}}Code Snippets
Download and install a package, specified by its import path
go get {{path/to/package}}Compile and run a source file (it has to contain a `main` package)
go run {{file}}.goCompile a source file into a named executable
go build -o {{executable}} {{file}}.goCompile the package present in the current directory
go buildExecute all test cases of the current package (files have to end with `_test.go`)
go testContext
tldr-pages: common/go
Revisions (0)
No revisions yet.