From ec61d8a68a790f0da061cda87460e5fdd484ba1f Mon Sep 17 00:00:00 2001 From: Matthieu MOREL Date: Mon, 3 Jun 2024 15:01:00 +0200 Subject: [PATCH] enable gofmt and goimports linter (#646) Signed-off-by: Matthieu MOREL --- .golangci.yml | 4 ++++ mdstat_test.go | 7 +++++-- net_conntrackstat_test.go | 10 +++++----- net_udp_test.go | 10 +++++----- proc_test.go | 6 +++--- sysfs/class_thermal.go | 3 ++- 6 files changed, 24 insertions(+), 16 deletions(-) diff --git a/.golangci.yml b/.golangci.yml index 126df9e67..d7476d56e 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -3,6 +3,8 @@ linters: enable: - errcheck - godot + - gofmt + - goimports - gosimple - govet - ineffassign @@ -18,5 +20,7 @@ linter-settings: exclude: # Ignore "See: URL" - 'See:' + goimports: + local-prefixes: github.com/prometheus/procfs misspell: locale: US diff --git a/mdstat_test.go b/mdstat_test.go index adeb2bb10..7a577edc5 100644 --- a/mdstat_test.go +++ b/mdstat_test.go @@ -13,8 +13,11 @@ package procfs -import "testing" -import "github.com/google/go-cmp/cmp" +import ( + "testing" + + "github.com/google/go-cmp/cmp" +) func TestFS_MDStat(t *testing.T) { fs := getProcFixtures(t) diff --git a/net_conntrackstat_test.go b/net_conntrackstat_test.go index b19222a4f..67aa18dee 100644 --- a/net_conntrackstat_test.go +++ b/net_conntrackstat_test.go @@ -34,7 +34,7 @@ func TestParseConntrackStat(t *testing.T) { } want := []ConntrackStatEntry{ - ConntrackStatEntry{ + { Entries: 33, Found: 0, Invalid: 3, @@ -45,7 +45,7 @@ func TestParseConntrackStat(t *testing.T) { EarlyDrop: 0, SearchRestart: 0, }, - ConntrackStatEntry{ + { Entries: 33, Found: 0, Invalid: 2, @@ -56,7 +56,7 @@ func TestParseConntrackStat(t *testing.T) { EarlyDrop: 0, SearchRestart: 2, }, - ConntrackStatEntry{ + { Entries: 33, Found: 0, Invalid: 1, @@ -67,7 +67,7 @@ func TestParseConntrackStat(t *testing.T) { EarlyDrop: 0, SearchRestart: 1, }, - ConntrackStatEntry{ + { Entries: 33, Found: 0, Invalid: 47, @@ -96,7 +96,7 @@ func TestParseOldConntrackStat(t *testing.T) { } want := []ConntrackStatEntry{ - ConntrackStatEntry{ + { Entries: 43, Searched: 202143, Found: 48658538, diff --git a/net_udp_test.go b/net_udp_test.go index 657616109..0db53bffd 100644 --- a/net_udp_test.go +++ b/net_udp_test.go @@ -30,7 +30,7 @@ func Test_newNetUDP(t *testing.T) { name: "udp file found, no error should come up", file: "testdata/fixtures/proc/net/udp", want: []*netIPSocketLine{ - &netIPSocketLine{ + { Sl: 0, LocalAddr: net.IP{10, 0, 0, 5}, LocalPort: 22, @@ -43,7 +43,7 @@ func Test_newNetUDP(t *testing.T) { Inode: 2740, Drops: intToU64(100), }, - &netIPSocketLine{ + { Sl: 1, LocalAddr: net.IP{0, 0, 0, 0}, LocalPort: 22, @@ -56,7 +56,7 @@ func Test_newNetUDP(t *testing.T) { Inode: 2740, Drops: intToU64(100), }, - &netIPSocketLine{ + { Sl: 2, LocalAddr: net.IP{0, 0, 0, 0}, LocalPort: 22, @@ -76,7 +76,7 @@ func Test_newNetUDP(t *testing.T) { name: "udp6 file found, no error should come up", file: "testdata/fixtures/proc/net/udp6", want: []*netIPSocketLine{ - &netIPSocketLine{ + { Sl: 1315, LocalAddr: net.IP{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, LocalPort: 5355, @@ -89,7 +89,7 @@ func Test_newNetUDP(t *testing.T) { Inode: 21040, Drops: intToU64(0), }, - &netIPSocketLine{ + { Sl: 6073, LocalAddr: net.IP{254, 128, 0, 0, 0, 0, 0, 0, 86, 225, 173, 255, 254, 124, 102, 9}, LocalPort: 51073, diff --git a/proc_test.go b/proc_test.go index 239e35b17..ecf889acb 100644 --- a/proc_test.go +++ b/proc_test.go @@ -257,9 +257,9 @@ func TestFileDescriptorsInfo(t *testing.T) { sort.Sort(fdinfos) var want = ProcFDInfos{ ProcFDInfo{FD: "0", Pos: "0", Flags: "02004000", MntID: "13", InotifyInfos: []InotifyInfo{ - InotifyInfo{WD: "3", Ino: "1", Sdev: "34", Mask: "fce"}, - InotifyInfo{WD: "2", Ino: "1300016", Sdev: "fd00002", Mask: "fce"}, - InotifyInfo{WD: "1", Ino: "2e0001", Sdev: "fd00000", Mask: "fce"}, + {WD: "3", Ino: "1", Sdev: "34", Mask: "fce"}, + {WD: "2", Ino: "1300016", Sdev: "fd00002", Mask: "fce"}, + {WD: "1", Ino: "2e0001", Sdev: "fd00000", Mask: "fce"}, }}, ProcFDInfo{FD: "1", Pos: "0", Flags: "02004002", MntID: "13", InotifyInfos: nil}, ProcFDInfo{FD: "10", Pos: "0", Flags: "02004002", MntID: "9", InotifyInfos: nil}, diff --git a/sysfs/class_thermal.go b/sysfs/class_thermal.go index ab9048f53..10f4a9a76 100644 --- a/sysfs/class_thermal.go +++ b/sysfs/class_thermal.go @@ -23,8 +23,9 @@ import ( "strings" "syscall" - "github.com/prometheus/procfs/internal/util" fsp "io/fs" + + "github.com/prometheus/procfs/internal/util" ) // ClassThermalZoneStats contains info from files in /sys/class/thermal/thermal_zone