Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .golangci.next.reference.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2519,6 +2519,7 @@ linters:
- asciicheck
- bidichk
- bodyclose
- canonicalheader
- containedctx
- contextcheck
- copyloopvar
Expand Down Expand Up @@ -2633,6 +2634,7 @@ linters:
- asciicheck
- bidichk
- bodyclose
- canonicalheader
- containedctx
- contextcheck
- copyloopvar
Expand Down
1 change: 1 addition & 0 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ require (
github.com/kulti/thelper v0.6.3
github.com/kunwardeep/paralleltest v1.0.10
github.com/kyoh86/exportloopref v0.1.11
github.com/lasiar/canonicalheader v1.0.5
github.com/ldez/gomoddirectives v0.2.4
github.com/ldez/tagliatelle v0.5.0
github.com/leonklingele/grouper v1.1.2
Expand Down
2 changes: 2 additions & 0 deletions go.sum

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions jsonschema/golangci.next.jsonschema.json
Original file line number Diff line number Diff line change
Expand Up @@ -215,6 +215,7 @@
"asciicheck",
"bidichk",
"bodyclose",
"canonicalheader",
"containedctx",
"contextcheck",
"copyloopvar",
Expand Down
19 changes: 19 additions & 0 deletions pkg/golinters/canonicalheader/canonicalheader.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
package canonicalheader

import (
"github.com/lasiar/canonicalheader"
"golang.org/x/tools/go/analysis"

"github.com/golangci/golangci-lint/pkg/goanalysis"
)

func New() *goanalysis.Linter {
a := canonicalheader.Analyzer

return goanalysis.NewLinter(
a.Name,
a.Doc,
[]*analysis.Analyzer{a},
nil,
).WithLoadMode(goanalysis.LoadModeTypesInfo)
}
11 changes: 11 additions & 0 deletions pkg/golinters/canonicalheader/canonicalheader_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
package canonicalheader_test

import (
"testing"

"github.com/golangci/golangci-lint/test/testshared/integration"
)

func TestFromTestdata(t *testing.T) {
integration.RunTestdata(t)
}
19 changes: 19 additions & 0 deletions pkg/golinters/canonicalheader/testdata/canonicalheader.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
//golangcitest:args -Ecanonicalheader
package testdata

import "net/http"

func canonicalheader() {
v := http.Header{}

v.Get("Test-HEader") // want `non-canonical header "Test-HEader", instead use: "Test-Header"`
v.Set("Test-HEader", "value") // want `non-canonical header "Test-HEader", instead use: "Test-Header"`
v.Add("Test-HEader", "value") // want `non-canonical header "Test-HEader", instead use: "Test-Header"`
v.Del("Test-HEader") // want `non-canonical header "Test-HEader", instead use: "Test-Header"`
v.Values("Test-HEader") // want `non-canonical header "Test-HEader", instead use: "Test-Header"`

v.Set("Test-Header", "value")
v.Add("Test-Header", "value")
v.Del("Test-Header")
v.Values("Test-Header")
}
7 changes: 7 additions & 0 deletions pkg/lint/lintersdb/builder_linter.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import (
"github.com/golangci/golangci-lint/pkg/golinters/asciicheck"
"github.com/golangci/golangci-lint/pkg/golinters/bidichk"
"github.com/golangci/golangci-lint/pkg/golinters/bodyclose"
"github.com/golangci/golangci-lint/pkg/golinters/canonicalheader"
"github.com/golangci/golangci-lint/pkg/golinters/containedctx"
"github.com/golangci/golangci-lint/pkg/golinters/contextcheck"
"github.com/golangci/golangci-lint/pkg/golinters/copyloopvar"
Expand Down Expand Up @@ -154,6 +155,12 @@ func (LinterBuilder) Build(cfg *config.Config) ([]*linter.Config, error) {
WithPresets(linter.PresetPerformance, linter.PresetBugs).
WithURL("https://github.com/timakin/bodyclose"),

linter.NewConfig(canonicalheader.New()).
WithSince("v1.58.0").
WithPresets(linter.PresetStyle).
WithLoadForGoAnalysis().
WithURL("https://github.com/lasiar/canonicalHeader"),

linter.NewConfig(containedctx.New()).
WithSince("1.44.0").
WithLoadForGoAnalysis().
Expand Down