gitee.com/wgliang/goreporter@v0.0.0-20180902115603-df1b20f7c5d0/linters/golint/README.md (about) 1 Golint is a linter for Go source code. 2 3 [![Build Status](https://travis-ci.org/golang/lint.svg?branch=master)](https://travis-ci.org/golang/lint) 4 5 ## Installation 6 7 Golint requires Go 1.6 or later. 8 9 go get -u github.com/golang/lint/golint 10 11 ## Usage 12 13 Invoke `golint` with one or more filenames, directories, or packages named 14 by its import path. Golint uses the same 15 [import path syntax](https://golang.org/cmd/go/#hdr-Import_path_syntax) as 16 the `go` command and therefore 17 also supports relative import paths like `./...`. Additionally the `...` 18 wildcard can be used as suffix on relative and absolute file paths to recurse 19 into them. 20 21 The output of this tool is a list of suggestions in Vim quickfix format, 22 which is accepted by lots of different editors. 23 24 ## Purpose 25 26 Golint differs from gofmt. Gofmt reformats Go source code, whereas 27 golint prints out style mistakes. 28 29 Golint differs from govet. Govet is concerned with correctness, whereas 30 golint is concerned with coding style. Golint is in use at Google, and it 31 seeks to match the accepted style of the open source Go project. 32 33 The suggestions made by golint are exactly that: suggestions. 34 Golint is not perfect, and has both false positives and false negatives. 35 Do not treat its output as a gold standard. We will not be adding pragmas 36 or other knobs to suppress specific warnings, so do not expect or require 37 code to be completely "lint-free". 38 In short, this tool is not, and will never be, trustworthy enough for its 39 suggestions to be enforced automatically, for example as part of a build process. 40 Golint makes suggestions for many of the mechanically checkable items listed in 41 [Effective Go](https://golang.org/doc/effective_go.html) and the 42 [CodeReviewComments wiki page](https://golang.org/wiki/CodeReviewComments). 43 44 If you find an established style that is frequently violated, and which 45 you think golint could statically check, 46 [file an issue](https://github.com/golang/lint/issues). 47 48 ## Contributions 49 50 Contributions to this project are welcome, though please send mail before 51 starting work on anything major. Contributors retain their copyright, so we 52 need you to fill out 53 [a short form](https://developers.google.com/open-source/cla/individual) 54 before we can accept your contribution. 55 56 ## Vim 57 58 Add this to your ~/.vimrc: 59 60 set rtp+=$GOPATH/src/github.com/golang/lint/misc/vim 61 62 If you have multiple entries in your GOPATH, replace `$GOPATH` with the right value. 63 64 Running `:Lint` will run golint on the current file and populate the quickfix list. 65 66 Optionally, add this to your `~/.vimrc` to automatically run `golint` on `:w` 67 68 autocmd BufWritePost,FileWritePost *.go execute 'Lint' | cwindow 69 70 71 ## Emacs 72 73 Add this to your `.emacs` file: 74 75 (add-to-list 'load-path (concat (getenv "GOPATH") "/src/github.com/golang/lint/misc/emacs")) 76 (require 'golint) 77 78 If you have multiple entries in your GOPATH, replace `$GOPATH` with the right value. 79 80 Running M-x golint will run golint on the current file. 81 82 For more usage, see [Compilation-Mode](http://www.gnu.org/software/emacs/manual/html_node/emacs/Compilation-Mode.html).