add golangci config file, make sure http resp body is closed

This commit is contained in:
cubixle
2021-08-04 23:49:27 +01:00
parent b3edf90eeb
commit 3e5c1d0e26
2 changed files with 108 additions and 0 deletions

106
.golangci.yml Normal file
View File

@@ -0,0 +1,106 @@
# options for analysis running
run:
# default concurrency
concurrency: 2
# timeout
deadline: 20s
# include test file
tests: false
# which dirs to skip
skip-dirs:
- example
# which files to skip
skip-files:
# exit code when at least one issue was found
issues-exit-code: 1
# output configuration options
output:
format: colored-line-number
print-issued-lines: true
print-linter-name: true
# all available settings of specific linters
linters-settings:
errcheck:
check-type-assertions: true
check-blank: true
govet:
check-shadowing: true
gofmt:
simplify: true
goconst:
min-len: 3
min-occurrences: 3
misspell:
locale: UK
unused:
check-exported: false
unparam:
algo: cha
nakedret:
max-func-lines: 30
prealloc:
simple: true
range-loops: true
for-loops: true
linters:
enable:
- deadcode
- govet
- ineffassign
- staticcheck
- structcheck
- typecheck
- unused
- varcheck
- bodyclose
- depguard
- dupl
- goconst
- gofmt
- goimports
- gosec
- misspell
- nakedret
- prealloc
- unconvert
issues:
exclude-use-default: false
exclude:
# errcheck: Almost all programs ignore errors on these functions and in most cases it's ok
- Error return value of
.((os\.)?std(out|err)\..*|.*Close|.*Flush|os\.Remove(All)?|.*printf?|os\.(Un)?Setenv).
is not checked
# golint: Exported variables are rarely used and generally reserved for errors which should be self explanitory
- exported var \w+ should have comment or be unexported
# golint: False positive when tests are defined in package 'test'
- func name will be used as test\.Test.* by other packages, and that
stutters; consider calling this
# gas: Too many false-positives on 'unsafe' usage
- Use of unsafe calls should be audited
# gas: Too many false-positives for parametrized shell calls
- Subprocess launch(ed with variable|ing should be audited)
# gas: Duplicated errcheck checks
- G104
# gas: Too many issues in popular repos
- (Expect directory permissions to be 0750 or less|Expect file permissions
to be 0600 or less)
# gas: False positive is triggered by 'src, err := ioutil.ReadFile(filename)'
- Potential file inclusion via variable
# govet: Common false positives
- (possible misuse of unsafe.Pointer|should have signature)
# megacheck: Developers tend to write in C-style with an explicit 'break' in a 'switch', so it's ok to ignore
- ineffective break statement. Did you mean to break out of the outer loop