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 buildbuilds package discards results.go installbuilds installs package in$gopath/pkgdirectory.
for commands (package main)
go buildbuilds command , leaves result in current working directory.go installbuilds 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