Closed
Description
Welcome
- Yes, I'm using a binary release within 2 latest major releases. Only such installations are supported.
- Yes, I've searched similar issues on GitHub and didn't find any.
- Yes, I've read the typecheck section of the FAQ (https://golangci-lint.run/usage/faq/#why-do-you-have-typecheck-errors).
- Yes, I've tried with the standalone linter if available (e.g., gocritic, go vet, etc.). (https://golangci-lint.run/usage/linters/)
Description of the problem
I found that the goconst setting ignore-calls
has different behavior between 1.54.2 and 1.55.2, and not work as expection on v1.55.2.
My code:
package main
import (
"net/http"
)
func main() {
var token1 = "token1"
var token2 = "token2"
var request1 = http.Request{Header: make(http.Header)}
request1.Header.Add("Authorization", "Bearer "+token1)
var request2 = http.Request{Header: make(http.Header)}
request2.Header.Add("Authorization", "Bearer "+token2)
}
There are two request2.Header.Add()
functions to add "Authorization" headers to request.
Because I turn on the ignore-calls
, I think there wounldn't be any error. It's indeed no error on the old version of golanglint-ci v1.54.2, but the v1.55.2 reports an error:
$ ./golangci-lint-v1.54.2 version
golangci-lint has version 1.54.2 built with go1.21.0 from 411e0bbb on 2023-08-21T12:04:32Z
$ ./golangci-lint-v1.54.2 run
$ ./golangci-lint-v1.55.2 version
golangci-lint has version 1.55.2 built with go1.21.3 from e3c2265f on 2023-11-03T12:59:25Z
$ ./golangci-lint-v1.55.2 run
main.go:12:39: string `Bearer ` has 2 occurrences, make it a constant (goconst)
request1.Header.Add("Authorization", "Bearer "+token1)
^
Version of golangci-lint
v1.55.2
Configuration
linters-settings:
goconst:
min-len: 2
min-occurrences: 2
ignore-calls: true
linters:
disable-all: true
enable:
- goconst
run:
timeout: 5m
Go environment
go version go1.21.5 linux/amd64
Verbose output of running
Output from v1.55.2:
$ ./golangci-lint-v1.55.2 version
golangci-lint has version 1.55.2 built with go1.21.3 from e3c2265f on 2023-11-03T12:59:25Z
$ ./golangci-lint-v1.55.2 run
main.go:12:39: string `Bearer ` has 2 occurrences, make it a constant (goconst)
request1.Header.Add("Authorization", "Bearer "+token1)
^
Output from v1.54.2:
$ ./golangci-lint-v1.54.2 version
golangci-lint has version 1.54.2 built with go1.21.0 from 411e0bbb on 2023-08-21T12:04:32Z
$ ./golangci-lint-v1.54.2 run
A minimal reproducible example or link to a public repository
package main
import (
"net/http"
)
func main() {
var token1 = "token1"
var token2 = "token2"
var request1 = http.Request{Header: make(http.Header)}
request1.Header.Add("Authorization", "Bearer "+token1)
var request2 = http.Request{Header: make(http.Header)}
request2.Header.Add("Authorization", "Bearer "+token2)
}
Validation
- Yes, I've included all information above (version, config, etc.).