←back to thread

Hyrum's Law in Golang

(abenezer.org)
98 points thunderbong | 2 comments | | HN request time: 0s | source
Show context
raverbashing ◴[] No.42202306[source]
It's like an inverted game of cat and mice

1 - Lang/OS/Lib developer puts out a quirky or buggy API (or even just an ok API)

2 - Developers rely on a quirky, weird or unexpected side effect because it's easier/more obvious or it just works this way due to a bug

3 - Original developer can't fix it because it would break compatibility

4 GOTO 1

replies(2): >>42202332 #>>42202389 #
1. Cthulhu_ ◴[] No.42202389[source]
And this isn't even quirky/buggy, it's just the string representation of an error. That said, Go took a while to improve its core error mechanisms and add utilities for matching errors by type instead of its string representation.
replies(1): >>42203387 #
2. simiones ◴[] No.42203387[source]
In this case, it really is - because until Go 1.19, that function simply returned `errors.New("http: request body too large")`. So until Go 1.19, there really was no other way to check if this error occurred than `err.String() == "http: request body too large"`. Even if we had had errors.Is/As earlier, it wouldn't have helped in this case.