Skip to content

Instantly share code, notes, and snippets.

@jandre
Last active August 29, 2015 14:09
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 jandre/e3d3052d88a3e7335ed4 to your computer and use it in GitHub Desktop.
Save jandre/e3d3052d88a3e7335ed4 to your computer and use it in GitHub Desktop.
gomeetup
build a go lib and binary
1. installing go
1. OS X: brew install go
2. Linux: https://github.com/dcoxall/vagrant-golang ?
3. organizing your code
1. GOPATH export GOPATH=/Users/jandre/godemo
2. WORKSPACE https://golang.org/doc/code.html
3. vim go (https://github.com/fatih/vim-go)
4. :GoInstallBinaries
5. code
1. create a lib (exporting functions)
1. package naming
2. exporting functions
3. how to build (go build)
3. create a binary that consumes lib
1. demo how goimports auto imports stuff from stdlib
2. package = main
5. create a tests (go test)
6. goroutines (NOT COVERED)
7. documentation
1. Use full sentences (e.g. https://github.com/tools/godep/blob/master/main.go#L13-L33)
2. godoc.org: e.g. http://godoc.org/github.com/jandre/procfs
9. importing other libraries (use debug example) and go get
10. structs, objects
11. pointers?
11. reflection?
12. managing dependencies (https://github.com/tools/godep)
1. how you want to organize things? e.g. using a makefile (to set GOPATH, setup deps, etc)
7. references!
1. http://www.golang-book.com/
2. https://gist.github.com/jandre/8216047
8. code examples
1. web stuff - gogs.io https://github.com/gogits/gogs
2. simple project to learn from: https://github.com/sourcegraph/go-papertrail/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment