Go cli: Difference between revisions
Jump to navigation
Jump to search
Line 38: | Line 38: | ||
</syntaxhighlight> | </syntaxhighlight> | ||
[[File:Go CLi Tree2.png|200px]] | [[File:Go CLi Tree2.png|200px]] | ||
==Install== | |||
Go install will do all of what build will do but will also create the bin and the library in the workspace. e.g. | |||
<syntaxhighlight lang="bash"> | |||
go install mds/hello | |||
</syntaxhighlight> | |||
[[File:Go Cli tree3.png|200px]] |
Revision as of 02:48, 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
Install
Go install will do all of what build will do but will also create the bin and the library in the workspace. e.g.
go install mds/hello