Skip to content

Commit

Permalink
fix: do not use deprecated ioutil
Browse files Browse the repository at this point in the history
  • Loading branch information
caarlos0 committed Aug 29, 2022
1 parent aef18e6 commit a18f050
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 6 deletions.
4 changes: 2 additions & 2 deletions internal/collector/domain_test.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package collector

import (
"io/ioutil"
"io"
"net/http"
"net/http/httptest"
"regexp"
Expand Down Expand Up @@ -46,7 +46,7 @@ func testCollector(t *testing.T, collector prometheus.Collector, checker func(t

resp, err := http.Get(srv.URL)
is.NoErr(err) // expected no error
body, err := ioutil.ReadAll(resp.Body)
body, err := io.ReadAll(resp.Body)
is.NoErr(err) // expected no error
checker(t, resp.StatusCode, string(body))
}
4 changes: 2 additions & 2 deletions internal/safeconfig/safeconfig.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ package safeconfig

import (
"fmt"
"io/ioutil"
"os"
"path/filepath"

"github.com/rs/zerolog/log"
Expand Down Expand Up @@ -35,7 +35,7 @@ func (cfg *SafeConfig) Reload(pathToFile string) error {
}
log.Debug().Msgf("absolute path of config file is %s", filename)

yamlFile, err := ioutil.ReadFile(filename)
yamlFile, err := os.ReadFile(filename)
if err != nil {
return fmt.Errorf("failed to read file: %w", err)
}
Expand Down
3 changes: 1 addition & 2 deletions internal/safeconfig/safeconfig_test.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package safeconfig

import (
"io/ioutil"
"os"
"reflect"
"testing"
Expand Down Expand Up @@ -82,7 +81,7 @@ domains:
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
file, err := ioutil.TempFile(os.TempDir(), "temp.*.yaml")
file, err := os.CreateTemp(os.TempDir(), "temp.*.yaml")
if err != nil {
log.Fatal().Err(err)
}
Expand Down

0 comments on commit a18f050

Please sign in to comment.