new go programmers don't know or confused fundamental go build command does.
what go build
, go install
commands build , put result/output?
this q&a in spirit of knowledge sharing / documenting.
what go
command depends on whether run "normal" package or special "main"
package.
for packages
go build
builds package discards results.go install
builds installs package in$gopath/pkg
directory.
for commands (package main
)
go build
builds command , leaves result in current working directory.go install
builds command in temporary directory moves$gopath/bin
.
so can use go build
check packages can built (along dependencies) while go install
(permanently) installs results in proper folders of $gopath
.
go build
silently terminate if ok, , give error messages if packages cannot built/compiled.
whenever go
tool installs package or binary, installs whatever dependencies has, running go install
install packages program depends on (publicly available, "go gettable" packages), automatically.
for start, read official how write go code page.
more information go
tool: command go
you can more running following command:
go build
it worth noting starting go 1.5 go install
removes executables created go build
(source):
if 'go install' (with no arguments, meaning current directory) succeeds, remove executable written 'go build', if present. avoids leaving stale binary behind...
to complete list, go run
compiles application temporary folder, , starts executable binary. when app exists, cleans temporary files.
question inspired dave cheney's what go build build?
Comments
Post a Comment