Better HN
topnewbestaskshowjobs
Log inSign up

jminter

4 karma · joined Oct 4, 2013 (13y ago) · 3 submissions

Submissions

comment 1y ago · link · parent

Absolutely. An intermediate path in Go is to recover any panics on your goroutines: in this case a nil dereference panic may cause the death of the goroutine but not the whole application.

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

Nice post!

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

The argument laid out in this article is a quite complicated edifice, and requires a large amount of knowledge at the intersection of several fields of study

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?