4 karma · joined Oct 4, 2013 (13y ago) · 3 submissions
comment 1y ago · link · parent
An example where this can be useful is in HTTP request handling: a single request might fail but the others can keep going -- but there are plenty of other use cases too.
The panic recovery code can log for further investigation, as well as in the HTTP case for example probably returning a 500 to the caller if wanted.
There are of course plenty of valid reasons not to take an approach like this too, but in some circumstances it can be useful.
comment 3y ago · link · parent
To me, "math/big" feels like a big hammer for working on an int64; a nice alternative is "encoding/binary":
func atomSlug(publishedAt time.Time) string {
b := make([]byte, 0, 8)
b = binary.BigEndian.AppendUint64(b, uint64(publishedAt.Unix()))
b = bytes.TrimLeft(b, "\x00")
return lexicographicBase32Encoding.EncodeToString(b)
}comment 4y ago · link · parent
I found this blog post interesting and wish it had a bibliography. Could anyone recommend some approachable sources to read more about the general themes in this post?