In the go source code I read lately I found that most often err
is used when it comes to naming error variables. I personally always preferred plain e
(mainly because it is 66.6% shorter).
To increase my code compatibility I decided to get some data about that. Two greps (powered by silversearcher) on the code in the stdlib later I had some numbers I could work with:
/usr/local/go/src$ e=$(ag " e := " | wc -l); echo $e
334
/usr/local/go/src$ err=$(ag " err := " | wc -l); echo $err
4128
/usr/local/go/src$ echo "100.0 * $err / ($e + $err)" | bc -l
92.51456745853877185118
So I decided that 92.5% is definitely worth updating my snippets (and habits).
@davecheney was so kind to give me some detailed explanation about this unwritten naming convention: "tradition"
(Source: https://twitter.com/tobstarr/status/519037483439628289)