LinuxCommandLibrary

golint

TLDR

Lint current package

$ golint .
copy
Lint specific file
$ golint [file.go]
copy
Lint package recursively
$ golint ./...
copy
Set minimum confidence
$ golint -min_confidence [0.8] ./...
copy

SYNOPSIS

golint [options] [packages]

DESCRIPTION

golint checks Go source code for style issues. It enforces the style guidelines from Effective Go and the Go Code Review Comments, focusing on naming conventions, comments, and code structure.
Unlike go vet which finds bugs, golint focuses on style and readability. Issues are suggestions, not errors.

PARAMETERS

-min_confidence n

Minimum confidence for issues (0.0-1.0).
-set_exit_status
Exit with non-zero status on issues.
packages
Package paths to lint.

COMMON ISSUES

$ - Exported functions should have comments
- Package comments should be of the form "Package x..."
- Receiver names should be consistent
- Don't use underscores in Go names
- Error strings should not be capitalized
copy

CAVEATS

Deprecated in favor of staticcheck or golangci-lint. Suggestions are stylistic, not bugs. High false-positive rate for some projects. Not actively maintained.

HISTORY

golint was created by the Go team at Google as a style checker. It was deprecated in 2021 in favor of more comprehensive linters like staticcheck. The project recommends using golangci-lint which includes multiple linters.

SEE ALSO

Copied to clipboard