Merge branch 'chore/replace-ioutils-with-os-calls' into 'main'
chore: replace ioutil with os calls See merge request hectorjsmith/fail2ban-prometheus-exporter!95
This commit is contained in:
commit
d1b65a2134
@ -1,11 +1,12 @@
|
|||||||
package textfile
|
package textfile
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"github.com/prometheus/client_golang/prometheus"
|
|
||||||
"io/ioutil"
|
|
||||||
"log"
|
"log"
|
||||||
|
"os"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
|
"github.com/prometheus/client_golang/prometheus"
|
||||||
)
|
)
|
||||||
|
|
||||||
const namespace = "textfile"
|
const namespace = "textfile"
|
||||||
@ -19,7 +20,7 @@ var (
|
|||||||
)
|
)
|
||||||
|
|
||||||
func (c *Collector) collectFileContents() {
|
func (c *Collector) collectFileContents() {
|
||||||
files, err := ioutil.ReadDir(c.folderPath)
|
files, err := os.ReadDir(c.folderPath)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Printf("error reading directory '%s': %v", c.folderPath, err)
|
log.Printf("error reading directory '%s': %v", c.folderPath, err)
|
||||||
return
|
return
|
||||||
@ -36,7 +37,7 @@ func (c *Collector) collectFileContents() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fullPath := filepath.Join(c.folderPath, fileName)
|
fullPath := filepath.Join(c.folderPath, fileName)
|
||||||
content, err := ioutil.ReadFile(fullPath)
|
content, err := os.ReadFile(fullPath)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
c.appendErrorForPath(fileName)
|
c.appendErrorForPath(fileName)
|
||||||
log.Printf("error reading contents of file '%s': %v", fileName, err)
|
log.Printf("error reading contents of file '%s': %v", fileName, err)
|
||||||
|
Loading…
Reference in New Issue
Block a user