Go(lang) - goatandsheep/goatandsheep.github.com GitHub Wiki

  • pkg: internal libraries, i.e. homemade stuff
  • vendor: dependencies

Dependency manager: dep does not replace go get https://golang.github.io/dep/docs/FAQ.html#does-dep-replace-go-get

dep ensure <library> for libraries

go get ./...

pkg in tld is like compiled garbage of links like in C

Go will pull the top of master for each dependency, so using vendor will ensure the version you need is available.

Pointers

Pass them only if you want to mutate the item directly

Error Handling

  • Use panic('error message') sparingly: kills the entire application
  • Pipelining: Check for errors and bubble them up to the top

Function Definition

func(<structs you need>) FunctionName(<parameters>) <output type> {}

Types

  • cast: []string()
  • convert: []string{}

Marshalling

  • Marshall: doesn't take pointer, makes a copy
  • Umarshall: takes a pointer, only returns error and mutates message
⚠️ **GitHub.com Fallback** ⚠️