From dc342e3051330d1bf4e26aebbb7f2817b8f011c9 Mon Sep 17 00:00:00 2001 From: Hector Date: Thu, 22 Jun 2023 14:33:56 +0000 Subject: [PATCH] chore: replace ioutil with os calls (!95) * Replace calls to deprecated `ioutil` functions with the `os` package https://gitlab.com/hectorjsmith/fail2ban-prometheus-exporter/-/merge_requests/95 --- collector/textfile/file.go | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/collector/textfile/file.go b/collector/textfile/file.go index 7ed5de7..7591511 100644 --- a/collector/textfile/file.go +++ b/collector/textfile/file.go @@ -1,11 +1,12 @@ package textfile import ( - "github.com/prometheus/client_golang/prometheus" - "io/ioutil" "log" + "os" "path/filepath" "strings" + + "github.com/prometheus/client_golang/prometheus" ) const namespace = "textfile" @@ -19,7 +20,7 @@ var ( ) func (c *Collector) collectFileContents() { - files, err := ioutil.ReadDir(c.folderPath) + files, err := os.ReadDir(c.folderPath) if err != nil { log.Printf("error reading directory '%s': %v", c.folderPath, err) return @@ -36,7 +37,7 @@ func (c *Collector) collectFileContents() { } fullPath := filepath.Join(c.folderPath, fileName) - content, err := ioutil.ReadFile(fullPath) + content, err := os.ReadFile(fullPath) if err != nil { c.appendErrorForPath(fileName) log.Printf("error reading contents of file '%s': %v", fileName, err)