Printing Data

https://golang.org/pkg/fmt/

%v prints structs, and %+v includes parameter names

spew.Dump(var) is a Data::Dumper replacement using go-spew

Errors

Creating Errors

Out of the box, you can do:

errors.New("...")

fmt.Errorf("%s", s)

Checking Errors

if err := doThing(); err != nil {
	// handle error
}
// continue

Wrapping Errors

Wrapping an error lets you add context to the original error.

<aside> 💡 This uses [github.com/pkg/errors](<http://github.com/pkg/errors>) rather than the standard errors package

</aside>

errors.Wrap(err, "additional context about what caused the error")

Time

When defining a date format, you don’t use the standard %Y-%M-%D formatting. Instead you write the date Mon Jan 2 15:04:05 -0700 MST 2006 in your desired format, and it figures it out!