Last active
August 12, 2023 01:18
-
-
Save pantafive/3296201ef3dc14a71139cae157aa8c34 to your computer and use it in GitHub Desktop.
golangci config
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
run: | |
# timeout for analysis, e.g. 30s, 5m, default is 1m | |
timeout: 10m | |
# exit code when at least one issue was found, default is 1 | |
issues-exit-code: 1 | |
# include test files or not, default is true | |
tests: true | |
# list of build tags, all linters use it. Default is empty list. | |
# build-tags: | |
# - mytag | |
# which dirs to skip: issues from them won't be reported; | |
# can use regexp here: generated.*, regexp is applied on full path; | |
# default value is empty list, but default dirs are skipped independently | |
# from this option's value (see skip-dirs-use-default). | |
# "/" will be replaced by current OS file path separator to properly work | |
# on Windows. | |
# skip-dirs: | |
# - src/external_libs | |
# - autogenerated_by_my_lib | |
# default is true. Enables skipping of directories: | |
# vendor$, third_party$, testdata$, examples$, Godeps$, builtin$ | |
skip-dirs-use-default: true | |
# which files to skip: they will be analyzed, but issues from them | |
# won't be reported. Default value is empty list, but there is | |
# no need to include all autogenerated files, we confidently recognize | |
# autogenerated files. If it's not please let us know. | |
# "/" will be replaced by current OS file path separator to properly work | |
# on Windows. | |
# skip-files: | |
# - ".*\\.my\\.go$" | |
# - lib/bad.go | |
# by default isn't set. If set we pass it to "go list -mod={option}". From "go help modules": | |
# If invoked with -mod=readonly, the go command is disallowed from the implicit | |
# automatic updating of go.mod described above. Instead, it fails when any changes | |
# to go.mod are needed. This setting is most useful to check that go.mod does | |
# not need updates, such as in a continuous integration and testing system. | |
# If invoked with -mod=vendor, the go command assumes that the vendor | |
# directory holds the correct copies of dependencies and ignores | |
# the dependency descriptions in go.mod. | |
# modules-download-mode: readonly|vendor|mod | |
# Allow multiple parallel golangci-lint instances running. | |
# If false (default) - golangci-lint acquires file lock on start. | |
allow-parallel-runners: false | |
# Define the Go version limit. | |
# Mainly related to generics support in go1.18. | |
# Default: use Go version from the go.mod file, fallback on the env var `GOVERSION`, fallback on 1.17 | |
go: '1.20' | |
linters: | |
enable-all: true | |
disable: | |
- deadcode # [deprecated]: Finds unused code [fast: false, auto-fix: false] | |
- exhaustivestruct # [deprecated]: Checks if all struct's fields are initialized [fast: false, auto-fix: false] | |
- exhaustruct # : Checks if all structure fields are initialized [fast: false, auto-fix: false] | |
- forbidigo # : Forbids identifiers [fast: true, auto-fix: false] | |
- gochecknoinits # : Checks that no init functions are present in Go code [fast: true, auto-fix: false] | |
- godot # : Check if comments end in a period [fast: true, auto-fix: true] | |
- godox # : Tool for detection of FIXME, TODO and other comment keywords [fast: true, auto-fix: false] | |
- golint # [deprecated]: Golint differs from gofmt. Gofmt reformats Go source code, whereas golint prints out style mistakes [fast: false, auto-fix: false] | |
- ifshort # [deprecated]: Checks that your code uses short syntax for if-statements whenever possible [fast: true, auto-fix: false] | |
- interfacer # [deprecated]: Linter that suggests narrower interface types [fast: false, auto-fix: false] | |
- ireturn # : Accept Interfaces, Return Concrete Types [fast: true, auto-fix: false] | |
- lll # : Reports long lines [fast: true, auto-fix: false] | |
- maligned # [deprecated]: Tool to detect Go structs that would take less memory if their fields were sorted [fast: false, auto-fix: false] | |
- nlreturn # : nlreturn checks for a new line before return and branch statements to increase code clarity [fast: true, auto-fix: false] | |
- nosnakecase # [deprecated]: nosnakecase is a linter that detects snake case of variable naming and function name. [fast: true, auto-fix: false] | |
- paralleltest # : paralleltest detects missing usage of t.Parallel() method in your Go test [fast: true, auto-fix: false] | |
- scopelint # [deprecated]: Scopelint checks for unpinned variables in go programs [fast: true, auto-fix: false] | |
- structcheck # [deprecated]: Finds unused struct fields [fast: false, auto-fix: false] | |
- testpackage # : linter that makes you use a separate _test package [fast: true, auto-fix: false] | |
- varcheck # [deprecated]: Finds unused global variables and constants [fast: false, auto-fix: false] | |
- varnamelen #: checks that the length of a variable's name matches its scope [fast: false, auto-fix: false] | |
- wrapcheck # : Checks that errors returned from external packages are wrapped [fast: false, auto-fix: false] | |
- wsl # : Whitespace Linter - Forces you to use empty lines! [fast: true, auto-fix: false] | |
# output configuration options | |
output: | |
# colored-line-number|line-number|json|tab|checkstyle|code-climate|junit-xml|github-actions | |
# default is "colored-line-number" | |
format: line-number | |
# print lines of code with issue, default is true | |
print-issued-lines: false | |
# print linter name in the end of issue text, default is true | |
print-linter-name: true | |
# make issues output unique by line, default is true | |
# uniq-by-line: true | |
# add a prefix to the output file references; default is no prefix | |
# path-prefix: "" | |
# sorts results by: filepath, line and column | |
sort-results: true | |
# all available settings of specific linters | |
linters-settings: | |
gocritic: | |
# Enable multiple checks by tags, run `GL_DEBUG=gocritic golangci-lint run` to see all tags and checks. | |
# Empty list by default. See https://github.com/go-critic/go-critic#usage -> section "Tags". | |
enabled-tags: | |
- diagnostic | |
- experimental | |
- opinionated | |
- performance | |
- style | |
disabled-checks: | |
- commentedOutCode | |
- commentFormatting | |
- hugeParam # does not work with generics | |
- typeDefFirst # does not work with generics | |
- whyNoLint | |
gocyclo: | |
# Minimal code complexity to report. | |
# Default: 30 (but we recommend 10-20) | |
min-complexity: 10 | |
goimports: | |
local-prefixes: github.com/user/project | |
gci: | |
sections: | |
- standard # Standard section: captures all standard packages. | |
- default # Default section: contains all imports that could not be matched to another section type. | |
- prefix(github.com/user/project) # Custom section: groups all imports with the specified Prefix. | |
- blank # Blank section: contains all blank imports. This section is not present unless explicitly enabled. | |
- dot # Dot section: contains all dot imports. This section is not present unless explicitly enabled. | |
skip-generated: true | |
custom-order: true | |
gofumpt: | |
lang-version: '1.20' | |
extra-rules: true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
- repo: https://github.com/golangci/golangci-lint | |
rev: v1.54.1 | |
hooks: | |
- id: golangci-lint | |
entry: golangci-lint run --fix | |
require_serial: true | |
verbose: true |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment