- $GOPATH is the well known place where
go
looks for things and installs built things. go install <path>
<path>
is relative to$GOPATH\src
.
For example, the following will attempt to compile code found in $GOPATH/src/my-app
:
$> go install my-app
-
go install
doesn't care ifpackage <name>
matches the fs path structure. -
When the name of a package is
main
, that package ends up in$GOPATH/bin
as an executable. -
You must define
main
func when the package ismain
- aka you wanted an executable package. If you don't definemain
, you'll see:
runtime.main: call to external function main.main runtime.main: main.main: not defined runtime.main: undefined: main.main
1. Any package installed in `$GOPATH/pkg` can be `import`ed.
1. Dependencies `imported` will be built and installed when the parent is built
and installed... turtles!
1.