linters-settings: depguard: list-type:blacklist packages: # logging is allowed only by logutils.Log, logrus # is allowed to use only in logutils package -github.com/sirupsen/logrus dupl: threshold:100 funlen: lines:100 statements:50 goconst: min-len:2 min-occurrences:3 gocritic: enabled-tags: -diagnostic -performance -style enable-checks: -builtinShadow# in opinionated group -importShadow# in opinionated group -paramTypeCombine# in opinionated group gocyclo: min-complexity:20 golint: min-confidence:0 gomnd: settings: mnd: # don't include the "operation" and "assign" checks:argument,case,condition,return lll: line-length:150 misspell: locale:US govet: check-shadowing:true maligned: suggest-new:true nolintlint: allow-leading-space:true# don't require machine-readable nolint directives (i.e. with no leading space) allow-unused:false# report any unused nolint directives require-explanation:false# don't require an explanation for nolint directives require-specific:false# don't require nolint directives to be specific about which linter is being skipped
1.exported type T should have comment or be unexported 要暴露出去的结构体或者函数都应该写注释
2.comment on exported type U should be of the form "U …" 定义的type要被使用,对函数或者type写注释,注释要以函数名或type名字开头。在以"_test.go"结尾的文件,不应该要求写注释 eg: // H is a type type H int
3.a blank import should be only in a main or test package, or have a comment justifying it import时要使用'_'时,要写注释。在main package或者测试文件中不需要写注释
4.exported const Whatsit should have comment (or a comment on this block) or be unexported const模块要添加注释
5.context.Context should be the first parameter of a function context参数要放在函数参数的第一个,当min-confidence 大于0.9时会忽略,小于等于0.9会显示
6.should not use basic type string as key in context.WithValue context.WithValue的key参数不能是基本类型
7.if block ends with a return statement, so drop this else and outdent its block 如果else中包含return语句,则去掉整个else把else中的语句移到外面。
8.error should be the last type when returning multiple items 返回参数中有error时,把error作为返回参数的最后一个参数。当min-confidence大于0.9时会忽略,小于等于0.9时会显示
9.should replace errors.New(fmt.Sprintf(…)) with fmt.Errorf(…) 如果想打印指定的error内容,应该使用error.New(fmt.Sprintf(...))。
10.error var should have name of the form errFoo 给error.New()声明一个变量应该使用err或者Err开头。当min-confidence大于0.9时会忽略,小于等于0.9时会显示
11.error strings should not be capitalized or end with punctuation or a newline error信息不应该以大写字母开头或者以标点符号或者换行结尾。当min-confidence大于0.8时会忽略,小于等于0.8时会显示
12.should not use dot imports 不应该使用'.'导入y--
13.should replace x += 1 with x++ x += 1应该用x++;y-=1应该用y--。当min-confidence大于0.8时会忽略,小于等于0.8时会显示
14.don’t use an underscore in package name 包名中不应该使用'_'。error信息不应该以大写字母开头或者以标点符号或者换行结尾。当min-confidence大于0.9时会忽略,小于等于0.9时会显示
15.don’t use underscores in Go names 变量名、函数名、参数名(入参,返回参数)不应该使用下划线,应该使用驼峰命名法。当min-confidence大于0.9时会忽略,小于等于0.9时会显示
16.struct field Url should be URL 简写应该都大写。'URL','ID','qID','isEOF'等。当min-confidence大于0.8时会忽略,小于等于0.8时会显示
17.don’t use ALL_CAPS in Go names; use CamelCase 不要用全大写加下划线。当min-confidence大于0.8时会忽略,小于等于0.8时会显示
18.don’t use leading k in Go names const修饰的常量不能以小写字母'k'接大写字母开头。当min-confidence大于0.8时会忽略,小于等于0.8时会显示
19.don’t use MixedCaps in package name go的包名不要使用大小写混合,应该全小写
20.should have a package comment, unless it’s in another file for this package 应该对包写注释。当min-confidence大于0.2时会忽略,小于等于0.2时会显示
21.package comment should be of the form "Package testdata …" 包的注释应该以"Package packagename"开头
22.package comment should not have leading space 包注释最前面不应该有空格
23.package comment is detached; there should be no blank lines between it and the package statement 包注释和'package'之间不应该有空格。当min-confidence大于0.9时会忽略,小于等于0.9时会显示
24.should omit 2nd value from range; this loop is equivalent to for x := range ... 用range写for循环时,如果第二个参数不需要,可以直接写成 for x:= range ... for x,_ = range ... ===> for x := range ...
25.should omit values from range; this loop is equivalent to for range ... 如果range循环两个参数都不需要,可以写成 for range ... for _,_ = range ... || for _ = range ... ===> for range ...
26.receiver name should be a reflection of its identity; don’t use generic names such as “this” or "self" 结构体的方法,引用结构体的名称应该要关联结构体 func (this foo) f1() ===> func (f foo) f1()
27.receiver name should not be an underscore, omit the name if it is unused 结构体的方法,引用结构体的名称不应该使用'_'。如果没有使用,删除它
28.receiver name a should be consistent with previous receiver name b for bar 同一结构体的方法,引用结构体的名称应该一致
29.exported method U.Other should have comment or be unexported 对外暴露的结构体对应的方法应该有注释
30.type name will be used as donut.DonutMaker by other packages, and that stutters; consider calling this Maker 对外暴露的结构体或者变量,命名时不应该以包名作为前缀。例如你的包名叫'dount',要定义一个结构体,结构体的名称应该用'Maker',不应该使用'DountMaker',因为别的包导入的时候会用'dount.Maker',使用'dount.DountMaker'会有信息冗余。当min-confidence大于0.8时会忽略,小于等于0.8时会显示
31.*var rpcTimeoutMsec is of type time.Duration; don’t use unit-specific suffix “Msec” 如果变量的结果是 *time.Duration类型,不要用'Msec'或者'Secs'结尾。当min-confidence大于0.9时会忽略,小于等于0.9时会显示
32.exported func Exported returns unexported type foo.hidden, which can be annoying to use 非该结构体的要暴露的函数返回参数为该结构体。这样用起来会很麻烦。当min-confidence大于0.8时会忽略,小于等于0.8时会显示