%v
prints structs, and %+v
includes parameter names
spew.Dump(var)
is a Data::Dumper replacement using go-spew
Out of the box, you can do:
errors.New("...")
fmt.Errorf("%s", s)
if err := doThing(); err != nil {
// handle error
}
// continue
Wrapping an error lets you add context to the original error.
<aside>
💡 This uses github.com/pkg/errors
rather than the standard errors
package
</aside>
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!