根据做者的说法:git
Golint is a linter for Go source code. Golint differs from gofmt. Gofmt reformats Go source code, whereas golint prints out style mistakes. Golint differs from govet. Govet is concerned with correctness, whereas golint is concerned with coding style. Golint is in use at Google, and it seeks to match the accepted style of the open source Go project.
一句话就是Golint用于检查go代码中不够规范的地方。github
一、下载golang 的 lint,下载地址:https://github.com/golang/lintgolang
二、解压文件到$GOPATH/src/github.com/golang/lintui
三、到目录$GOPATH/src/github.com/golang/lint/golint中运行go build ./this
四、在当前目录有golint的可执行程序code
固然,最简单的方式是:orm
go get github.com/golang/lint go install github.com/golang/lint
golint 文件名或者目录
检查结果以下:get
import-dot.go:6:8: should not use dot imports else.go:11:9: if block ends with a return statement, so drop this else and outdent its block sort.go:11:1: exported method T.Len should have comment or be unexported sort.go:20:1: exported method U.Other should have comment or be unexported
从上面输出能够看到,golint对go代码给出的建议。string
golint 会检查的内容:it
变量名规范 变量的声明,像var str string = "test",会有警告,应该var str = "test" 大小写问题,大写导出包的要有注释 x += 1 应该 x++ 等等……
若是使用命令下载安装不通的状况下,建议使用第一种方法
在使用golint命令检查时,须要把golint.exe文件放在你要检查的名录下,这样在使用命令时才能找到该执行程序。