Go cli: Difference between revisions
Jump to navigation
Jump to search
Line 23: | Line 23: | ||
Compiles but does not run a program. Given the tree | Compiles but does not run a program. Given the tree | ||
<br> | <br> | ||
[[File:Go cli tree.png]] | [[File:Go cli tree.png|200px]] | ||
<br> | <br> | ||
This command will build the library but not produce anything. | This command will build the library but not produce anything. |
Revision as of 02:41, 30 January 2021
Introduction
This is just a page on go command options
go help <command>
// e.g.
go help test
We can go to https://golang.org/cmd/go/ for online
Building and Running
Environment
For me I have set up my PATH to include go and my GOROOT to be the parent directory of the src folder.
export PATH=/usr/local/go/bin:$PATH
cd blah1/blah2/src/..
export GOPATH=`pwd`
Run
Compiles and run a program without leaving artefacts.
go run src/cmds/hello/hello.go
Build
Compiles but does not run a program. Given the tree
This command will build the library but not produce anything.
go build hello
This command will build the binary and produce a binary
go build cmds/hello
Adding the -i forces the intermediate files to be created on disk in the pkg directory
go build -i cmds/hello