Skip to content

Commit 932b950

Browse files
committed
chore: refactor linting configuration and improve test error handling
- Update `.golangci.yml` to version 2 - Replace `enable-all` and `disable-all` with `default: none` in `.golangci.yml` - Remove specific linters from `.golangci.yml` - Add exclusions and formatters sections to `.golangci.yml` - Replace `ioutil.TempFile` with `os.CreateTemp` in `local_file_test.go` - Change error handling in `local_file_test.go` to use `t.Fatalf` instead of `t.Error` Signed-off-by: Bo-Yi Wu <[email protected]>
1 parent e2855e0 commit 932b950

File tree

2 files changed

+25
-15
lines changed

2 files changed

+25
-15
lines changed

.golangci.yml

Lines changed: 23 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,18 @@
1+
version: "2"
12
linters:
2-
enable-all: false
3-
disable-all: true
4-
fast: false
3+
default: none
54
enable:
65
- bodyclose
76
- dogsled
87
- dupl
98
- errcheck
10-
- exportloopref
119
- exhaustive
1210
- gochecknoinits
1311
- goconst
1412
- gocritic
1513
- gocyclo
16-
- gofmt
17-
- goimports
1814
- goprintffuncname
1915
- gosec
20-
- gosimple
2116
- govet
2217
- ineffassign
2318
- lll
@@ -27,13 +22,29 @@ linters:
2722
- nolintlint
2823
- rowserrcheck
2924
- staticcheck
30-
- stylecheck
31-
- typecheck
3225
- unconvert
3326
- unparam
3427
- unused
3528
- whitespace
29+
exclusions:
30+
generated: lax
31+
presets:
32+
- comments
33+
- common-false-positives
34+
- legacy
35+
- std-error-handling
36+
paths:
37+
- third_party$
38+
- builtin$
39+
- examples$
40+
formatters:
41+
enable:
42+
- gofmt
3643
- gofumpt
37-
38-
run:
39-
timeout: 3m
44+
- goimports
45+
exclusions:
46+
generated: lax
47+
paths:
48+
- third_party$
49+
- builtin$
50+
- examples$

local_file_test.go

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
package static
22

33
import (
4-
"io/ioutil"
54
"os"
65
"path/filepath"
76
"testing"
@@ -13,9 +12,9 @@ import (
1312
func TestLocalFile(t *testing.T) {
1413
// SETUP file
1514
testRoot, _ := os.Getwd()
16-
f, err := ioutil.TempFile(testRoot, "")
15+
f, err := os.CreateTemp(testRoot, "")
1716
if err != nil {
18-
t.Error(err)
17+
t.Fatalf("Failed to create temp file: %v", err)
1918
}
2019
defer os.Remove(f.Name())
2120
_, err = f.WriteString("Gin Web Framework")

0 commit comments

Comments
 (0)