golint错误检查以及 min-confidence 不同等级的错误提示

本文探讨了golint工具在进行代码规范检查时,如何根据min-confidence设置调整错误提示的严格程度。默认情况下,golint对所有错误进行严格提示,但当min-confidence大于1时,所有错误都被接受。文章列举了一系列golint常见的错误提示,包括导出类型注释、错误处理、上下文使用、命名规范等方面,帮助开发者理解并改进Go代码质量。
摘要由CSDN通过智能技术生成

golint错误检查以及 min-confidence 不同等级的错误提示

未指出 min-confidence 在不同等级有不同区别的提示,默认都是严格显示的。当 mini-confidence 大于 1 时,所有错误都会被接受。

  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 co

评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值