From 1fb1e3e3e6507c829e288729b470d99eee2c2798 Mon Sep 17 00:00:00 2001 From: Matthieu MOREL Date: Tue, 4 Apr 2023 18:07:22 +0000 Subject: [PATCH] ci(lint): correct gci linter Signed-off-by: Matthieu MOREL --- .golangci.yml | 7 +++++++ cpu/cpu_linux.go | 3 ++- cpu/cpu_test.go | 3 ++- disk/disk_linux.go | 3 ++- host/host_linux.go | 3 ++- mem/mem_linux.go | 3 ++- mem/mem_test.go | 3 ++- net/net_linux_test.go | 5 ++++- process/process_linux.go | 5 +++-- process/process_posix.go | 3 ++- process/process_test.go | 3 ++- 11 files changed, 30 insertions(+), 11 deletions(-) diff --git a/.golangci.yml b/.golangci.yml index ac9a41ead..4d163db1a 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -46,3 +46,10 @@ linters: - structcheck - unused - varcheck + +linters-settings: + gci: + sections: + - standard + - default + - prefix(github.com/shirou) diff --git a/cpu/cpu_linux.go b/cpu/cpu_linux.go index 962d34300..d4c575e80 100644 --- a/cpu/cpu_linux.go +++ b/cpu/cpu_linux.go @@ -11,8 +11,9 @@ import ( "strconv" "strings" - "github.com/shirou/gopsutil/v3/internal/common" "github.com/tklauser/go-sysconf" + + "github.com/shirou/gopsutil/v3/internal/common" ) var ClocksPerSec = float64(100) diff --git a/cpu/cpu_test.go b/cpu/cpu_test.go index 91b8e8ad9..4202ce841 100644 --- a/cpu/cpu_test.go +++ b/cpu/cpu_test.go @@ -8,8 +8,9 @@ import ( "testing" "time" - "github.com/shirou/gopsutil/v3/internal/common" "github.com/stretchr/testify/assert" + + "github.com/shirou/gopsutil/v3/internal/common" ) func skipIfNotImplementedErr(t *testing.T, err error) { diff --git a/disk/disk_linux.go b/disk/disk_linux.go index b6a3adcf5..14712f9ea 100644 --- a/disk/disk_linux.go +++ b/disk/disk_linux.go @@ -16,8 +16,9 @@ import ( "strconv" "strings" - "github.com/shirou/gopsutil/v3/internal/common" "golang.org/x/sys/unix" + + "github.com/shirou/gopsutil/v3/internal/common" ) const ( diff --git a/host/host_linux.go b/host/host_linux.go index 2ff0c268e..adce92e2f 100644 --- a/host/host_linux.go +++ b/host/host_linux.go @@ -15,8 +15,9 @@ import ( "strconv" "strings" - "github.com/shirou/gopsutil/v3/internal/common" "golang.org/x/sys/unix" + + "github.com/shirou/gopsutil/v3/internal/common" ) type lsbStruct struct { diff --git a/mem/mem_linux.go b/mem/mem_linux.go index 9a5d693b1..56fb1cc6c 100644 --- a/mem/mem_linux.go +++ b/mem/mem_linux.go @@ -14,8 +14,9 @@ import ( "strconv" "strings" - "github.com/shirou/gopsutil/v3/internal/common" "golang.org/x/sys/unix" + + "github.com/shirou/gopsutil/v3/internal/common" ) type VirtualMemoryExStat struct { diff --git a/mem/mem_test.go b/mem/mem_test.go index 57734d778..3be56562f 100644 --- a/mem/mem_test.go +++ b/mem/mem_test.go @@ -6,8 +6,9 @@ import ( "runtime" "testing" - "github.com/shirou/gopsutil/v3/internal/common" "github.com/stretchr/testify/assert" + + "github.com/shirou/gopsutil/v3/internal/common" ) func skipIfNotImplementedErr(t *testing.T, err error) { diff --git a/net/net_linux_test.go b/net/net_linux_test.go index d5d6252a8..61f7e5a76 100644 --- a/net/net_linux_test.go +++ b/net/net_linux_test.go @@ -9,8 +9,9 @@ import ( "syscall" "testing" - "github.com/shirou/gopsutil/v3/internal/common" "github.com/stretchr/testify/assert" + + "github.com/shirou/gopsutil/v3/internal/common" ) func TestIOCountersByFileParsing(t *testing.T) { @@ -248,6 +249,7 @@ entries searched found new invalid ignore delete deleteList insert insertFailed // Function under test stats, err := conntrackStatsFromFile(tmpfile.Name(), true) + assert.Nil(t, err) assert.Equal(t, 8, len(stats), "Expected 8 results") summary := &ConntrackStat{} @@ -308,6 +310,7 @@ entries searched found new invalid ignore delete deleteList insert insertFailed // Test summary grouping totals, err := conntrackStatsFromFile(tmpfile.Name(), false) + assert.Nil(t, err) for i, st := range totals { assert.Equal(t, summary.Entries, st.Entries) assert.Equal(t, summary.Searched, st.Searched) diff --git a/process/process_linux.go b/process/process_linux.go index d5b5bc329..6dbef4c2f 100644 --- a/process/process_linux.go +++ b/process/process_linux.go @@ -16,11 +16,12 @@ import ( "strconv" "strings" + "github.com/tklauser/go-sysconf" + "golang.org/x/sys/unix" + "github.com/shirou/gopsutil/v3/cpu" "github.com/shirou/gopsutil/v3/internal/common" "github.com/shirou/gopsutil/v3/net" - "github.com/tklauser/go-sysconf" - "golang.org/x/sys/unix" ) var pageSize = uint64(os.Getpagesize()) diff --git a/process/process_posix.go b/process/process_posix.go index 88e2bff53..36c6a47ba 100644 --- a/process/process_posix.go +++ b/process/process_posix.go @@ -14,8 +14,9 @@ import ( "strings" "syscall" - "github.com/shirou/gopsutil/v3/internal/common" "golang.org/x/sys/unix" + + "github.com/shirou/gopsutil/v3/internal/common" ) type Signal = syscall.Signal diff --git a/process/process_test.go b/process/process_test.go index 40e3639fa..5d1cb2993 100644 --- a/process/process_test.go +++ b/process/process_test.go @@ -17,8 +17,9 @@ import ( "testing" "time" - "github.com/shirou/gopsutil/v3/internal/common" "github.com/stretchr/testify/assert" + + "github.com/shirou/gopsutil/v3/internal/common" ) var mu sync.Mutex