代码规范之Variable Names变量名
golang中
官方文档:https://go.dev/wiki/CodeReviewComments#variable-names
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.
Go语言中的变量名应该简短而不是冗长。局部变量尤其如此,它们的范围有限。c优于lineCount。i优于sliceIndex。
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.
基本规则:**名称使用距离其声明越远,名称就必须越具有描述性。**对于方法接收器,一到两个字母就足够了。常见的变量,例如循环索引和读取器,可以用单个字母(i,r)。更不常见的事物和全局变量需要更具描述性的名称。