Skip to content

Instantly share code, notes, and snippets.

@cromwellryan
Created April 13, 2016 16:41
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save cromwellryan/57d679fe08a1637124f924c956a72cdb to your computer and use it in GitHub Desktop.
Save cromwellryan/57d679fe08a1637124f924c956a72cdb to your computer and use it in GitHub Desktop.
  1. $GOPATH is the well known place where go looks for things and installs built things.
  2. 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
  1. go install doesn't care if package <name> matches the fs path structure.

  2. When the name of a package is main, that package ends up in $GOPATH/bin as an executable.

  3. You must define main func when the package is main - aka you wanted an executable package. If you don't define main, you'll see:

hello

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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment