Hacker News new | ask | show | jobs
by sagichmal 4393 days ago

    > 'idiomatic' is used as newspeak for 'not the style I 
    > personally recognize as being the true Go way'.
There is, in fact, a style which is "the true Go way".
1 comments

'idiomatic' is not an objective term, but people use it like if it were.

There's a true Go way, the style used in the stdlib; but even the stdlib is not consistent and you need to pick and choose. Then the standard library doesn't cover all possible cases.

My definition of idiomatic Go code is:

    1. It passes gofmt
    2. It passes govet
    3. It passes golint
    4. It checks it's errors.
    5. It looks like code in the stdlib.
    6. For the rest, it looks like code written by other 
       people that I recognize as being good Go developers.
    7. For the rest, it looks like my own code.
I think that's a stricter definition than what most people think of when they criticize code as being unidiomatic. However it's still very subjective. From 1 to 4 are objective measurements. Point 5 is somewhat subjective. Points 6 and 7 are simply a matter of my personal experience through life and how circumstances led me to encounter a specific subset of code; entirely subjective.
The definition of idiomatic Go code is go fmt, go vet, golint, and https://code.google.com/p/go-wiki/wiki/CodeReviewComments.