• Home
  • History
  • Annotate
Name Date Size #Lines LOC

..03-May-2022-

golint/H08-Dec-2020-484361

misc/H08-Dec-2020-8748

testdata/H08-Dec-2020-910517

.travis.ymlH A D08-Dec-2020230 2015

CONTRIBUTING.mdH A D08-Dec-2020412 1610

LICENSEH A D08-Dec-20201.4 KiB2824

README.mdH A D08-Dec-20203.5 KiB9059

go.modH A D08-Dec-202097 63

go.sumH A D08-Dec-20201.2 KiB1312

lint.goH A D08-Dec-202043.4 KiB1,6161,273

lint_test.goH A D08-Dec-20208.5 KiB318279

README.md

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