golangci-lint

goconst

  1. 同一个字符串出现次数>=2,应该改为常量定义
  • 错误提示
string 2012-09-01 has 2 occurrences, make it a constant (goconst)
  • 错误示例
a := "2012-09-01"

...

b := "2012-09-01"

...
  • 正确示例
const timeStr = "2012-09-01"

gocritic

  1. 导入的包名和自己的变量名重叠,容易造成误解
  • 错误提示
importShadow: shadow of imported from 'service/code' package 'code'
  • 错误示例
func QueryUserInfoByCode(code Code.code) ....
  • 正确示例
func QueryUserInfoByCode(reqCode Code.code) ....

golint

  1. 包名不要使用下划线
  • 错误提示
don't use an underscore in package name
  • 错误示例
package third_service
  • 正确示例
package thirdService