Printing Data

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

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


Creating Errors

Out of the box, you can do:


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 [](<>) rather than the standard errors package


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


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!