1Golint 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 7Golint requires a 8[supported release of Go](https://golang.org/doc/devel/release.html#policy). 9 10 go get -u golang.org/x/lint/golint 11 12To find out where `golint` was installed you can run `go list -f {{.Target}} golang.org/x/lint/golint`. For `golint` to be used globally add that directory to the `$PATH` environment setting. 13 14## Usage 15 16Invoke `golint` with one or more filenames, directories, or packages named 17by its import path. Golint uses the same 18[import path syntax](https://golang.org/cmd/go/#hdr-Import_path_syntax) as 19the `go` command and therefore 20also supports relative import paths like `./...`. Additionally the `...` 21wildcard can be used as suffix on relative and absolute file paths to recurse 22into them. 23 24The output of this tool is a list of suggestions in Vim quickfix format, 25which is accepted by lots of different editors. 26 27## Purpose 28 29Golint differs from gofmt. Gofmt reformats Go source code, whereas 30golint prints out style mistakes. 31 32Golint differs from govet. Govet is concerned with correctness, whereas 33golint is concerned with coding style. Golint is in use at Google, and it 34seeks to match the accepted style of the open source Go project. 35 36The suggestions made by golint are exactly that: suggestions. 37Golint is not perfect, and has both false positives and false negatives. 38Do not treat its output as a gold standard. We will not be adding pragmas 39or other knobs to suppress specific warnings, so do not expect or require 40code to be completely "lint-free". 41In short, this tool is not, and will never be, trustworthy enough for its 42suggestions to be enforced automatically, for example as part of a build process. 43Golint makes suggestions for many of the mechanically checkable items listed in 44[Effective Go](https://golang.org/doc/effective_go.html) and the 45[CodeReviewComments wiki page](https://golang.org/wiki/CodeReviewComments). 46 47## Scope 48 49Golint is meant to carry out the stylistic conventions put forth in 50[Effective Go](https://golang.org/doc/effective_go.html) and 51[CodeReviewComments](https://golang.org/wiki/CodeReviewComments). 52Changes that are not aligned with those documents will not be considered. 53 54## Contributions 55 56Contributions to this project are welcome provided they are [in scope](#scope), 57though please send mail before starting work on anything major. 58Contributors retain their copyright, so we need you to fill out 59[a short form](https://developers.google.com/open-source/cla/individual) 60before we can accept your contribution. 61 62## Vim 63 64Add this to your ~/.vimrc: 65 66 set rtp+=$GOPATH/src/golang.org/x/lint/misc/vim 67 68If you have multiple entries in your GOPATH, replace `$GOPATH` with the right value. 69 70Running `:Lint` will run golint on the current file and populate the quickfix list. 71 72Optionally, add this to your `~/.vimrc` to automatically run `golint` on `:w` 73 74 autocmd BufWritePost,FileWritePost *.go execute 'Lint' | cwindow 75 76 77## Emacs 78 79Add this to your `.emacs` file: 80 81 (add-to-list 'load-path (concat (getenv "GOPATH") "/src/golang.org/x/lint/misc/emacs/")) 82 (require 'golint) 83 84If you have multiple entries in your GOPATH, replace `$GOPATH` with the right value. 85 86Running M-x golint will run golint on the current file. 87 88For more usage, see [Compilation-Mode](http://www.gnu.org/software/emacs/manual/html_node/emacs/Compilation-Mode.html). 89