2016-09-24 17:03:48 +01:00
|
|
|
# go
|
|
|
|
|
2024-02-14 20:25:13 +00:00
|
|
|
> Manage Go source code.
|
2021-09-13 09:21:21 +01:00
|
|
|
> Some subcommands such as `go build` have their own usage documentation.
|
2019-06-07 11:58:25 +01:00
|
|
|
> More information: <https://golang.org>.
|
2016-09-24 17:03:48 +01:00
|
|
|
|
|
|
|
- Download and install a package, specified by its import path:
|
|
|
|
|
|
|
|
`go get {{package_path}}`
|
|
|
|
|
|
|
|
- Compile and run a source file (it has to contain a `main` package):
|
|
|
|
|
|
|
|
`go run {{file}}.go`
|
|
|
|
|
2017-09-28 10:20:26 +01:00
|
|
|
- Compile a source file into a named executable:
|
|
|
|
|
|
|
|
`go build -o {{executable}} {{file}}.go`
|
|
|
|
|
2016-09-24 17:03:48 +01:00
|
|
|
- Compile the package present in the current directory:
|
|
|
|
|
|
|
|
`go build`
|
|
|
|
|
|
|
|
- Execute all test cases of the current package (files have to end with `_test.go`):
|
|
|
|
|
|
|
|
`go test`
|
|
|
|
|
|
|
|
- Compile and install the current package:
|
|
|
|
|
|
|
|
`go install`
|
2020-03-27 12:47:07 +00:00
|
|
|
|
|
|
|
- Initialize a new module in the current directory:
|
|
|
|
|
|
|
|
`go mod init {{module_name}}`
|