mirror of
https://github.com/golang/go.git
synced 2025-05-05 15:43:04 +00:00
Revert 19fec6dcbba6fadcee2fd646d345ad5a911f96ec...59555a7a977fa183142a1fbc23222d61b58d165d on CodeReviewComments
parent
59555a7a97
commit
bd112e16b7
@ -598,8 +598,6 @@ In any case, the onus is on you to fail with a helpful message to whoever's debu
|
|||||||
|
|
||||||
## Variable Names
|
## Variable Names
|
||||||
|
|
||||||
Variable names in Go should be clear and descriptive rather than short. Exceptions can be made especially for local variables with limited scope or general conventions (e.g. coordinates: x y z; loops: i j k).
|
Variable names in Go should be short rather than long. This is especially true for local variables with limited scope. Prefer `c` to `lineCount`. Prefer `i` to `sliceIndex`.
|
||||||
|
|
||||||
Prefer `lineCount` to `c`. Prefer `sliceIndex` to `i`. Prefer `message` to `m`. Prefer `test` to `t`
|
The basic rule: the further from its declaration that a name is used, the more descriptive the name must be. For a method receiver, one or two letters is sufficient. Common variables such as loop indices and readers can be a single letter (`i`, `r`). More unusual things and global variables need more descriptive names.
|
||||||
|
|
||||||
The basic rule: avoid single letters variables
|
|
Loading…
x
Reference in New Issue
Block a user