5 ms·
Idiomatic Go is using shortened variable names, not what's in this article. I thought that was common knowledge and part of the Go ethos? I also wouldn't consid
by stevebmark 2y ago
Idiomatic Go is using shortened variable names, not what's in this article. I thought that was common knowledge and part of the Go ethos? I also wouldn't consider grammar in comments part of the language idioms? This is an unusual and very light take on Golang language idioms.
- emseetech 2y agoMy understanding is that shortened variable names are recommended for small, tight contexts (loops, short functions) but not generally.
- cube2222 2y agoThat and conventionally standard names, like r for request/reader, w for writer, etc. Agreed. Functions shouldn’t be full of short non-descriptly named variables. The longer the lifetime/scope of a variable, and the more variables there are, the more descriptive the names should be.
- GauntletWizard 2y agoThese are dang short compared to Java's FooBarBazBeanFactoryFuncClassImpl. The point you may be responding to is that "Short variable names" are themselves contextual. If you're doing a simple loop: for i := range personlist { person := personlist[i] ... } Is more readable than for personNum := range personlist { person := personlist[personNum] ... } because it makes clear that the i is basically irrelevant. The latter isn't bad style if you're three loops deep, because i, j, k is a bit harder to keep track of which is which.