From fc5df4e22f269d6a28e16820f9b029d155798d21 Mon Sep 17 00:00:00 2001 From: Ben Kochie Date: Mon, 23 Sep 2024 11:13:15 -0700 Subject: [PATCH] Forbid print statements (#668) Enable `forbidigo` to make sure print statements are not used in this library. This avoids injecting random log output into upstream user's log formatting. Signed-off-by: SuperQ --- .golangci.yml | 5 +++++ proc_smaps.go | 2 -- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/.golangci.yml b/.golangci.yml index d7476d56..e07e8211 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -2,6 +2,7 @@ linters: enable: - errcheck + - forbidigo - godot - gofmt - goimports @@ -15,6 +16,10 @@ linters: - unused linter-settings: + forbidigo: + forbid: + - p: ^fmt\.Print.*$ + msg: Do not commit print statements. godot: capital: true exclude: diff --git a/proc_smaps.go b/proc_smaps.go index 09060e82..07e7e650 100644 --- a/proc_smaps.go +++ b/proc_smaps.go @@ -19,7 +19,6 @@ package procfs import ( "bufio" "errors" - "fmt" "os" "regexp" "strconv" @@ -117,7 +116,6 @@ func (p Proc) procSMapsRollupManual() (ProcSMapsRollup, error) { func (s *ProcSMapsRollup) parseLine(line string) error { kv := strings.SplitN(line, ":", 2) if len(kv) != 2 { - fmt.Println(line) return errors.New("invalid net/dev line, missing colon") }