From fd83534698381b58b0215fdfaa46f66327600ea9 Mon Sep 17 00:00:00 2001 From: Daniel Date: Thu, 29 Sep 2022 14:31:00 +0200 Subject: [PATCH] Fix linter errors --- broadcasts/notify.go | 4 ++-- cmds/portmaster-start/lock.go | 5 ++--- cmds/updatemgr/release.go | 3 +-- compat/wfpstate.go | 3 +-- intel/filterlists/index.go | 4 ++-- netquery/chart_handler.go | 3 +-- netquery/query_handler.go | 3 +-- network/proc/findpid.go | 2 +- resolver/resolver-https.go | 4 ++-- 9 files changed, 13 insertions(+), 18 deletions(-) diff --git a/broadcasts/notify.go b/broadcasts/notify.go index 06e53148..cd6c38f2 100644 --- a/broadcasts/notify.go +++ b/broadcasts/notify.go @@ -5,7 +5,7 @@ import ( "encoding/json" "errors" "fmt" - "io/ioutil" + "os" "strings" "sync" "time" @@ -72,7 +72,7 @@ func broadcastNotify(ctx context.Context, t *modules.Task) error { if err != nil { return fmt.Errorf("failed to get broadcast notifications update: %w", err) } - broadcastsData, err := ioutil.ReadFile(broadcastsResource.Path()) + broadcastsData, err := os.ReadFile(broadcastsResource.Path()) if err != nil { return fmt.Errorf("failed to load broadcast notifications update: %w", err) } diff --git a/cmds/portmaster-start/lock.go b/cmds/portmaster-start/lock.go index 673844b3..23c4a6bb 100644 --- a/cmds/portmaster-start/lock.go +++ b/cmds/portmaster-start/lock.go @@ -3,7 +3,6 @@ package main import ( "errors" "fmt" - "io/ioutil" "log" "os" "path/filepath" @@ -17,7 +16,7 @@ func checkAndCreateInstanceLock(path, name string) (pid int32, err error) { lockFilePath := filepath.Join(dataRoot.Path, path, fmt.Sprintf("%s-lock.pid", name)) // read current pid file - data, err := ioutil.ReadFile(lockFilePath) + data, err := os.ReadFile(lockFilePath) if err != nil { if os.IsNotExist(err) { // create new lock @@ -78,7 +77,7 @@ func createInstanceLock(lockFilePath string) error { // create lock file // TODO: Investigate required permissions. - err = ioutil.WriteFile(lockFilePath, []byte(fmt.Sprintf("%d", os.Getpid())), 0o0666) //nolint:gosec + err = os.WriteFile(lockFilePath, []byte(fmt.Sprintf("%d", os.Getpid())), 0o0666) //nolint:gosec if err != nil { return err } diff --git a/cmds/updatemgr/release.go b/cmds/updatemgr/release.go index 908d2d44..e32b020c 100644 --- a/cmds/updatemgr/release.go +++ b/cmds/updatemgr/release.go @@ -4,7 +4,6 @@ import ( "context" "encoding/json" "fmt" - "io/ioutil" "os" "path/filepath" "time" @@ -124,7 +123,7 @@ func writeAsJSON(path string, data any) error { } // Write to disk. - err = ioutil.WriteFile(path, jsonData, 0o0644) //nolint:gosec + err = os.WriteFile(path, jsonData, 0o0644) //nolint:gosec if err != nil { return err } diff --git a/compat/wfpstate.go b/compat/wfpstate.go index 3e3bcf14..72f844c5 100644 --- a/compat/wfpstate.go +++ b/compat/wfpstate.go @@ -5,7 +5,6 @@ import ( "encoding/xml" "errors" "fmt" - "io/ioutil" "os" "path/filepath" "sort" @@ -42,7 +41,7 @@ func GetWFPState() (*SimplifiedWFPState, error) { } // Get tmp file contents. - output, err := ioutil.ReadFile(tmpFile) + output, err := os.ReadFile(tmpFile) if err != nil { return nil, fmt.Errorf("failed to read wfp state to tmp file: %w", err) } diff --git a/intel/filterlists/index.go b/intel/filterlists/index.go index a7081805..095e3ebd 100644 --- a/intel/filterlists/index.go +++ b/intel/filterlists/index.go @@ -3,7 +3,7 @@ package filterlists import ( "errors" "fmt" - "io/ioutil" + "os" "strings" "sync" @@ -212,7 +212,7 @@ func updateListIndex() error { } // Update list index from updates. - blob, err := ioutil.ReadFile(listIndexUpdate.Path()) + blob, err := os.ReadFile(listIndexUpdate.Path()) if err != nil { return err } diff --git a/netquery/chart_handler.go b/netquery/chart_handler.go index 04db0c8a..a44f03ac 100644 --- a/netquery/chart_handler.go +++ b/netquery/chart_handler.go @@ -7,7 +7,6 @@ import ( "errors" "fmt" "io" - "io/ioutil" "net/http" "strings" @@ -76,7 +75,7 @@ func (ch *ChartHandler) parseRequest(req *http.Request) (*QueryActiveConnectionC } var requestPayload QueryActiveConnectionChartPayload - blob, err := ioutil.ReadAll(body) + blob, err := io.ReadAll(body) if err != nil { return nil, fmt.Errorf("failed to read body" + err.Error()) } diff --git a/netquery/query_handler.go b/netquery/query_handler.go index baa1df1d..599c71ec 100644 --- a/netquery/query_handler.go +++ b/netquery/query_handler.go @@ -7,7 +7,6 @@ import ( "errors" "fmt" "io" - "io/ioutil" "net/http" "regexp" "strings" @@ -120,7 +119,7 @@ func (qh *QueryHandler) parseRequest(req *http.Request) (*QueryRequestPayload, e } var requestPayload QueryRequestPayload - blob, err := ioutil.ReadAll(body) + blob, err := io.ReadAll(body) if err != nil { return nil, fmt.Errorf("failed to read body" + err.Error()) } diff --git a/network/proc/findpid.go b/network/proc/findpid.go index 85902d14..693fb72f 100644 --- a/network/proc/findpid.go +++ b/network/proc/findpid.go @@ -116,7 +116,7 @@ func findSocketFromPid(pid int, socketName string) bool { return false } -// readDirNames only reads the directory names. Using ioutil.ReadDir() would call `lstat` on every +// readDirNames only reads the directory names. Using os.ReadDir() would call `lstat` on every // resulting directory name, which we don't need. This function will be called a lot, so we should // refrain from unnecessary work. func readDirNames(dir string) (names []string) { diff --git a/resolver/resolver-https.go b/resolver/resolver-https.go index be9b0d4b..b0ce489b 100644 --- a/resolver/resolver-https.go +++ b/resolver/resolver-https.go @@ -5,7 +5,7 @@ import ( "crypto/tls" "encoding/base64" "fmt" - "io/ioutil" + "io" "net/http" "net/url" "time" @@ -95,7 +95,7 @@ func (hr *HTTPSResolver) Query(ctx context.Context, q *Query) (*RRCache, error) }() // Try to read the result - body, err := ioutil.ReadAll(resp.Body) + body, err := io.ReadAll(resp.Body) if err != nil { return nil, err }