Skip to content

Commit c308871

Browse files
authored
chore: upgrade to golangci-lint v2 (#496)
* chore: upgrade to golangci-lint v2 * chore: golangci/[email protected]
1 parent 9342b7c commit c308871

File tree

9 files changed

+30
-19
lines changed

9 files changed

+30
-19
lines changed

Diff for: .github/workflows/pull_request.yml

+2-2
Original file line numberDiff line numberDiff line change
@@ -44,8 +44,8 @@ jobs:
4444
go-version: "^1.24.0"
4545
cache-dependency-path: go.sum
4646
- name: golangci-lint
47-
uses: golangci/golangci-lint-action@v6.5.2
47+
uses: golangci/golangci-lint-action@v7.0.0
4848
with:
49-
version: v1.64.6
49+
version: v2.0.2
5050
- run: go version
5151
- run: go test ./...

Diff for: .golangci.yml

+18-6
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,20 @@
1+
version: "2"
12
run:
23
tests: false
3-
issues:
4-
exclude-dirs:
5-
- pkg/worker
6-
- cmd/webworker
7-
- web
8-
- web/public/examples
4+
formatters:
5+
exclusions:
6+
paths:
7+
- "pkg/worker/"
8+
- "cmd/webworker/"
9+
- "web/"
10+
11+
linters:
12+
exclusions:
13+
rules:
14+
- text: ".Close` is not checked"
15+
linters:
16+
- errcheck
17+
paths:
18+
- "pkg/worker/"
19+
- "cmd/webworker/"
20+
- "web/"

Diff for: internal/builder/runner.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ type CommandRunner interface {
1313

1414
type OSCommandRunner struct{}
1515

16-
func (_ OSCommandRunner) RunCommand(cmd *exec.Cmd) error {
16+
func (OSCommandRunner) RunCommand(cmd *exec.Cmd) error {
1717
if err := cmd.Start(); err != nil {
1818
return err
1919
}

Diff for: internal/pkgindex/docutil/comments.go

+2-1
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,8 @@ func isDirective(c string) bool {
130130
continue
131131
}
132132
b := c[i]
133-
if !('a' <= b && b <= 'z' || '0' <= b && b <= '9') {
133+
ok := 'a' <= b && b <= 'z' || '0' <= b && b <= '9'
134+
if !ok {
134135
return false
135136
}
136137
}

Diff for: internal/pkgindex/docutil/filter.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ func NewIgnoreList(names ...string) Filter {
2929
// UnexportedFilter filters private symbols
3030
type UnexportedFilter struct{}
3131

32-
func (_ UnexportedFilter) Ignore(typeName string) bool {
32+
func (UnexportedFilter) Ignore(typeName string) bool {
3333
return !token.IsExported(typeName)
3434
}
3535

Diff for: internal/server/models.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ const (
2323

2424
type deprecatedMessage struct{}
2525

26-
func (_ deprecatedMessage) MarshalJSON() ([]byte, error) {
26+
func (deprecatedMessage) MarshalJSON() ([]byte, error) {
2727
return []byte(deprecationMsg), nil
2828
}
2929

Diff for: internal/server/response.go

+3-5
Original file line numberDiff line numberDiff line change
@@ -30,14 +30,12 @@ func (p FilesPayload) Validate() error {
3030
for name, src := range p.Files {
3131
switch filepath.Ext(name) {
3232
case ".go", ".mod":
33-
break
33+
if len(strings.TrimSpace(src)) == 0 {
34+
return fmt.Errorf("empty file %q", name)
35+
}
3436
default:
3537
return fmt.Errorf("invalid file type: %q", name)
3638
}
37-
38-
if len(strings.TrimSpace(src)) == 0 {
39-
return fmt.Errorf("empty file %q", name)
40-
}
4139
}
4240

4341
return nil

Diff for: internal/server/utils.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ func evalPayloadFromRequest(r *http.Request) ([]byte, error) {
3131
// See: https://github.com/golang/go/issues/68327
3232
if body.HasUnitTests() {
3333
return nil, errors.New(
34-
"Due to Go Playground bug, unit test snippets can't have multiple files.\n" +
34+
"due to Go Playground bug, unit test snippets can't have multiple files.\n" +
3535
"Please remove other Go files or use WebAssembly environment instead.\n\n" +
3636
"See: https://github.com/golang/go/issues/32403",
3737
)

Diff for: internal/util/buffutil/bufferpool.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ func (p *BufferPool) Put(b RecyclableBuffer) {
4343
panic("BufferPool.Put: RecyclableBuffer was already recycled")
4444
}
4545

46-
b.Buffer.Reset()
46+
b.Reset()
4747
p.pool.Put(b.Buffer)
4848
b.pool = nil
4949
b.Buffer = nil

0 commit comments

Comments
 (0)