From 6bb6fc41bfd3491ced1a5471ad803f5766c11b63 Mon Sep 17 00:00:00 2001 From: jason yang Date: Mon, 23 Oct 2023 03:16:25 +0000 Subject: [PATCH] fix lint Signed-off-by: jason yang --- .golangci.yml | 4 +++- internal/cgroup/parser/parser.go | 2 +- internal/cgroup/parser/parser_test.go | 12 ++++++------ 3 files changed, 10 insertions(+), 8 deletions(-) diff --git a/.golangci.yml b/.golangci.yml index 4077fe2..745cfa5 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -51,7 +51,9 @@ linters: - errcheck - thelper - usestdlibvars - - protogetter + - deadcode + - varcheck + - structcheck linters-settings: goheader: diff --git a/internal/cgroup/parser/parser.go b/internal/cgroup/parser/parser.go index 9f7010e..601f8f4 100644 --- a/internal/cgroup/parser/parser.go +++ b/internal/cgroup/parser/parser.go @@ -14,7 +14,7 @@ import ( ) type Marshal interface { - Marshal(*bytes.Buffer) (*bytes.Buffer, error) + Marshal(buffer *bytes.Buffer) (*bytes.Buffer, error) } type StatManager struct { diff --git a/internal/cgroup/parser/parser_test.go b/internal/cgroup/parser/parser_test.go index b4b05cd..5588490 100644 --- a/internal/cgroup/parser/parser_test.go +++ b/internal/cgroup/parser/parser_test.go @@ -19,18 +19,18 @@ func TestParser(t *testing.T) { require.Len(t, allFuncs, 5) usage := allFuncs[0]() - require.Equal(t, 0.0, usage["cpu_usage_per"]) + require.InEpsilon(t, 0.01, usage["cpu_usage_per"], 1) usage = allFuncs[1]() - require.Equal(t, 0.0, usage["memory_usage_per"]) + require.InEpsilon(t, 0.01, usage["memory_usage_per"], 1) usage = allFuncs[2]() - require.Equal(t, 0.0, usage["memory_swap_usage_per"]) + require.InEpsilon(t, 0.01, usage["memory_swap_usage_per"], 1) usage = allFuncs[3]() - require.Equal(t, 0.0, usage["pid_usage_per"]) + require.InEpsilon(t, 0.01, usage["pid_usage_per"], 1) usage = allFuncs[4]() - require.Equal(t, 0.0, usage["blkio_read"]) - require.Equal(t, 0.0, usage["blkio_write"]) + require.InEpsilon(t, 0.01, usage["blkio_read"], 1) + require.InEpsilon(t, 0.01, usage["blkio_write"], 1) }