tldr/pages/common/go.md
Augustin Grigorov 72114be857
go: add go modules (#3935)
* Add GO modules init command

Add command for initialising a new GO module. More about go modules: https://blog.golang.org/using-go-modules

Co-authored-by: Lucas Gabriel Schneider <casdpa@gmail.com>
2020-03-27 12:47:07 +00:00

669 B

go

Tool for managing go source code. More information: https://golang.org.

  • 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

  • Compile a source file into a named executable:

go build -o {{executable}} {{file}}.go

  • 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

  • Initialize a new module in the current directory:

go mod init {{module_name}}