2 ms·
> While Go has very deliberately not implemented class hierarchies, a quick perusal of Go's net and os packages should indicate that sometimes error hierarchies
by chimeracoder 12y ago
> While Go has very deliberately not implemented class hierarchies, a quick perusal of Go's net and os packages should indicate that sometimes error hierarchies are useful.
I just want to point out - I would hesitate from drawing too many conclusions from "net" and "os" (the latter in particular). Not only is "os" some of the oldest Go code, but it is also designed to wrap conveniently around external interfaces that follow very different idioms.
Another example would be the constant declarations[0], which use ALL_CAPS - this is actually not idiomatic in Go, but it is used here (a) because it was done very early on, and (b) because it more closely matches the C libraries it interfaces with[1].
I need to take a closer look at this errors package before drawing an opinion about the rest of it, but this sentence caught my attention.
[0] http://golang.org/pkg/os/#pkg-constants http://golang.org/pkg/os/#pkg-constants
[1] https://github.com/golang/lint/issues/32 https://github.com/golang/lint/issues/32