mirror of
https://github.com/cubixle/l1.git
synced 2026-04-24 22:54:47 +01:00
add golangci config file, make sure http resp body is closed
This commit is contained in:
106
.golangci.yml
Normal file
106
.golangci.yml
Normal 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
|
||||||
2
http.go
2
http.go
@@ -28,6 +28,8 @@ func DefaultHTTPTester(target string) *Result {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
result.Error = err
|
result.Error = err
|
||||||
}
|
}
|
||||||
|
defer rsp.Body.Close()
|
||||||
|
|
||||||
result.CompletedIn = float64(time.Since(startTime).Milliseconds())
|
result.CompletedIn = float64(time.Since(startTime).Milliseconds())
|
||||||
result.StatusCode = rsp.StatusCode
|
result.StatusCode = rsp.StatusCode
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user