Standard Library
Bytes
bytes.Equal
is a specialized way to compare byte slices. It’s much faster than simply comparing two slices with a for loop. Something worth being aware of, the bytes.Equal function considers empty and nil slices to be equal, while reflect.DeepEqual
does not.
bytes.Compare
function to compare two slices of bytes.
Logging
log.Fatal and log.Panic
When logging with the Go log package there’s a trap waiting for you in the log.Fatal
and log.Panic
functions. Unlike what you might expect of a logging function these don't simply log a message with a different log level, they also terminate the whole application. log.Fatal
cleanly exits the application, log.Panic
invokes a runtime panic. Here are the actual functions from the Go log package:
Time
time.LoadLocation reads from a file
To convert between time zones you first need to load location information. It turns out that time.LoadLocation
reads from a file every time it's called. Not the best thing to do when formatting each row of a massive CSV report:
Last updated
Was this helpful?