NHacker Next
  • new
  • past
  • show
  • ask
  • show
  • jobs
  • submit
Go Naming Conventions: A Practical Guide (alexedwards.net)
laserlight 11 minutes ago [-]
> we use the identifier p to represent a value in the people slice — the range block is so small and tight that using a single letter name is clear enough.

No, it's not. When you see `p.Age`, you have to go back and find the body of the loop, see what it operates on and decipher what p stands for. When you see `person.Age`, you understand it. I've never understood what is gained by using `p` instead of spelling it out as `person`.

qezz 2 hours ago [-]
I was surprised to see literally invalid names in the "bad" section, e.g. "Cannot start with a digit". Why even presenting this if it's rejected by the compiler?
0x696C6961 1 hours ago [-]
The example with the dash in it confused me as well.
nasretdinov 2 hours ago [-]
I like this article — short, accurate (which is somehow not a given these days...) and useful, just like Go language itself.
nacozarina 2 hours ago [-]
this seems anachronistic, written for a human artisan laboring over each naming choice directly

a modern approach would be a condensed ruleset passed to the ai model for the code it generates, and it should be straightforward to substitute different rulesets if you have a different taste in parochialisms.

johneth 2 hours ago [-]
> this seems anachronistic, written for a human artisan laboring over each naming choice directly

Some of us want to write well thought-through code, rather than letting an AI just spew poorly thought-through unmaintainable shit.

piekvorst 2 hours ago [-]
You can use this article to guide your choice of rulesets. And you still have to exert some artisan labor to develop any taste.

Parochialism here is saying “just use AI” in disguise.

jonathanstrange 41 minutes ago [-]
You're making yourself redundant if you don't keep your actual programming skills sharp.
andersonpico 1 hours ago [-]
[flagged]
red_admiral 3 hours ago [-]
Another of mine: don't name a struct after an interface method that it's supposed to implement. If you have a package linearalgebra, then making a custom error type linearalgebra.LinearAlgebraError is too "chatty" but linearalgebra.Error will cause you pain if it implements "Error string()", as it probably should, and you decide to make a linearalgebra.MatrixSingularError that wraps a linearalgebra.Error to "inherit" its methods.

In the end, it ended up called linearalgebra.Err .

P.S Alex Edwards' "let's go" and "let's go further" are great books to get someone up to date with golang, just keep an eye on features that are newer than the book(s).

DauntingPear7 2 hours ago [-]
The booms receive regular updates. I got an email about an update to Let’s Go Further on 3/12 for Go 1.26
Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact
Rendered at 13:51:14 GMT+0000 (Coordinated Universal Time) with Vercel.