Skip to content

Commit 3a1eed2

Browse files
authored
Merge pull request #355 from bobrik/ivan/golangci-lint-bump-v4
Bump golangci-lint to latest
2 parents 76d8ccb + 0972186 commit 3a1eed2

File tree

19 files changed

+43
-33
lines changed

19 files changed

+43
-33
lines changed

.github/workflows/ci.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -344,9 +344,9 @@ jobs:
344344
run: go mod verify
345345

346346
- name: Run golangci-lint
347-
uses: golangci/golangci-lint-action@c67416616c29c3c48d26b59c45cadb56966d80aa # https://github.com/golangci/golangci-lint-action/issues/953
347+
uses: golangci/golangci-lint-action@v4
348348
with:
349-
version: v1.54.2
349+
version: v1.56.2
350350
env:
351351
CGO_CFLAGS: "-I${{ github.workspace }}/libbpf/dest/usr/include"
352352

.golangci.yaml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,11 @@ linters:
55
- exhaustive
66
- exportloopref
77
- forcetypeassert
8+
- gochecksumtype
9+
- gofmt
810
- goimports
911
- gomoddirectives
12+
- inamedparam
1013
- interfacebloat
1114
- makezero
1215
- mirror
@@ -16,11 +19,13 @@ linters:
1619
- nilnil
1720
- nolintlint
1821
- nosprintfhostport
22+
- perfsprint
1923
- prealloc
2024
- predeclared
2125
- promlinter
2226
- reassign
2327
- revive
28+
- spancheck
2429
- stylecheck
2530
- tagalign
2631
- unconvert

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ endif
4343
.PHONY: lint
4444
lint:
4545
go mod verify
46-
golangci-lint run ./...
46+
CGO_LDFLAGS="$(CGO_LDFLAGS)" CGO_CFLAGS="$(CGO_CFLAGS)" golangci-lint run ./...
4747

4848
.PHONY: jsonschema
4949
jsonschema:

benchmark/getpid_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ import (
1212

1313
func init() {
1414
libbpfgoCallbacks := libbpfgo.Callbacks{}
15-
libbpfgoCallbacks.LogFilters = append(libbpfgoCallbacks.LogFilters, func(libLevel int, msg string) bool {
15+
libbpfgoCallbacks.LogFilters = append(libbpfgoCallbacks.LogFilters, func(libLevel int, _ string) bool {
1616
return libLevel == libbpfgo.LibbpfDebugLevel
1717
})
1818

cgroup/fanotify.go

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import (
44
"bufio"
55
"bytes"
66
"encoding/binary"
7+
"errors"
78
"fmt"
89
"io"
910
"log"
@@ -42,7 +43,7 @@ func newFanotifyMonitor(path string) (*fanotifyMonitor, error) {
4243
}
4344

4445
if !dacAllowed {
45-
return nil, fmt.Errorf("missing CAP_DAC_READ_SEARCH needed for open_by_handle_at in fanotify monitor")
46+
return nil, errors.New("missing CAP_DAC_READ_SEARCH needed for open_by_handle_at in fanotify monitor")
4647
}
4748

4849
mapping, err := walk(path)
@@ -86,11 +87,11 @@ func (m *fanotifyMonitor) readFanotifyLoop() error {
8687
}
8788

8889
if metadata.Mask&unix.FAN_CREATE == 0 {
89-
return fmt.Errorf("fanotify event for non-create event")
90+
return errors.New("fanotify event for non-create event")
9091
}
9192

9293
if metadata.Mask&unix.FAN_ONDIR == 0 {
93-
return fmt.Errorf("fanotify event for non-directory")
94+
return errors.New("fanotify event for non-directory")
9495
}
9596

9697
size := int(metadata.Event_len) - int(metadata.Metadata_len)

cgroup/monitor.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import (
55
)
66

77
type monitor interface {
8-
Resolve(int) string
8+
Resolve(id int) string
99
}
1010

1111
// Monitor resolves cgroup ids into their respective paths

cmd/ebpf_exporter/main.go

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

33
import (
4+
"errors"
45
"fmt"
56
"log"
67
"net/http"
@@ -38,7 +39,7 @@ func main() {
3839

3940
libbpfgoCallbacks := libbpfgo.Callbacks{Log: libbpfLogCallback}
4041
if !*debug {
41-
libbpfgoCallbacks.LogFilters = append(libbpfgoCallbacks.LogFilters, func(libLevel int, msg string) bool {
42+
libbpfgoCallbacks.LogFilters = append(libbpfgoCallbacks.LogFilters, func(libLevel int, _ string) bool {
4243
return libLevel == libbpfgo.LibbpfDebugLevel
4344
})
4445
}
@@ -109,7 +110,7 @@ func main() {
109110
}
110111

111112
http.Handle(*metricsPath, promhttp.Handler())
112-
http.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) {
113+
http.HandleFunc("/", func(w http.ResponseWriter, _ *http.Request) {
113114
_, err = w.Write([]byte(`<html>
114115
<head><title>eBPF Exporter</title></head>
115116
<body>
@@ -147,7 +148,7 @@ func listen(addr string) error {
147148
}
148149

149150
if len(listeners) < fd+1 {
150-
return fmt.Errorf("no listeners passed via activation")
151+
return errors.New("no listeners passed via activation")
151152
}
152153

153154
return http.Serve(listeners[fd], nil)

config/config.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ func ParseConfigs(dir string, names []string) ([]Config, error) {
9393
configs := make([]Config, len(names))
9494

9595
for i, name := range names {
96-
path := filepath.Join(dir, fmt.Sprintf("%s.yaml", name))
96+
path := filepath.Join(dir, name+".yaml")
9797

9898
f, err := os.Open(path)
9999
if err != nil {
@@ -114,7 +114,7 @@ func ParseConfigs(dir string, names []string) ([]Config, error) {
114114
return nil, fmt.Errorf("error validating config: %v", err)
115115
}
116116

117-
configs[i].BPFPath = filepath.Join(dir, fmt.Sprintf("%s.bpf.o", name))
117+
configs[i].BPFPath = filepath.Join(dir, name+".bpf.o")
118118
}
119119

120120
return configs, nil

decoder/decoder.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ var ErrSkipLabelSet = errors.New("this label set should be skipped")
1616
// to either use as an input for another Decoder or to use as the final
1717
// label value for Prometheus metrics
1818
type Decoder interface {
19-
Decode([]byte, config.Decoder) ([]byte, error)
19+
Decode(in []byte, conf config.Decoder) ([]byte, error)
2020
}
2121

2222
// Set is a set of Decoders that may be applied to produce a label

decoder/hex.go

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

33
import (
4-
"fmt"
4+
"encoding/hex"
55

66
"github.com/cloudflare/ebpf_exporter/v2/config"
77
)
@@ -11,5 +11,5 @@ type Hex struct{}
1111

1212
// Decode transforms bytes into their hex string representation
1313
func (u *Hex) Decode(in []byte, _ config.Decoder) ([]byte, error) {
14-
return []byte(fmt.Sprintf("%x", in)), nil
14+
return []byte(hex.EncodeToString(in)), nil
1515
}

0 commit comments

Comments
 (0)