diff --git a/config/file/config.go b/config/file/config.go index eeaa58c..0a7e15b 100644 --- a/config/file/config.go +++ b/config/file/config.go @@ -4,7 +4,6 @@ package file import ( "context" - "io/ioutil" "os" "path/filepath" "sync" @@ -27,7 +26,7 @@ type file struct { } func (c *file) Read() ([]byte, error) { - return ioutil.ReadFile(c.path) + return os.ReadFile(c.path) } // Watch listen for config changes and send updated content to the updates channel diff --git a/config/file/config_test.go b/config/file/config_test.go index fa331e2..7573288 100644 --- a/config/file/config_test.go +++ b/config/file/config_test.go @@ -4,7 +4,6 @@ package file import ( "context" - "io/ioutil" "os" "os/exec" "path" @@ -20,7 +19,7 @@ import ( func newConfigFile(t *testing.T) (config.Config, string, func()) { path := filepath.Join(os.TempDir(), "config.yaml") - if err := ioutil.WriteFile(path, []byte("ok"), os.ModePerm); err != nil { + if err := os.WriteFile(path, []byte("ok"), os.ModePerm); err != nil { t.Fatal(err) } cleanUp := func() { @@ -32,14 +31,14 @@ func newConfigFile(t *testing.T) (config.Config, string, func()) { } func newSymlinkedConfigFile(t *testing.T) (config.Config, string, string, func()) { - watchDir, err := ioutil.TempDir("", "") + watchDir, err := os.MkdirTemp("", "") require.Nil(t, err) dataDir1 := path.Join(watchDir, "data1") err = os.Mkdir(dataDir1, 0o777) require.Nil(t, err) realConfigFile := path.Join(dataDir1, "config.yaml") t.Logf("Real config file location: %s\n", realConfigFile) - err = ioutil.WriteFile(realConfigFile, []byte("foo: bar\n"), 0o640) + err = os.WriteFile(realConfigFile, []byte("foo: bar\n"), 0o640) require.Nil(t, err) cleanup := func() { os.RemoveAll(watchDir) @@ -64,7 +63,7 @@ func TestWatch(t *testing.T) { t.Fatal(err) } // when overwriting the file and waiting for the custom change notification handler to be triggered - err := ioutil.WriteFile(cpath, []byte("foo: baz\n"), 0o640) + err := os.WriteFile(cpath, []byte("foo: baz\n"), 0o640) b := <-updates // then the config value should have changed require.Nil(t, err) @@ -87,7 +86,7 @@ func TestWatch(t *testing.T) { err := os.MkdirAll(dataDir2, 0o777) require.NoError(t, err) configFile2 := path.Join(dataDir2, "config.yaml") - err = ioutil.WriteFile(configFile2, []byte("foo: baz\n"), 0o640) + err = os.WriteFile(configFile2, []byte("foo: baz\n"), 0o640) require.NoError(t, err) // change the symlink using the `ln -sfn` command err = exec.Command("ln", "-sfn", dataDir2, path.Join(watchDir, "data")).Run() diff --git a/example/example.go b/example/example.go index ed010b8..e5338bc 100644 --- a/example/example.go +++ b/example/example.go @@ -6,7 +6,6 @@ import ( "errors" "fmt" "io" - "io/ioutil" "net/http" "strings" "time" @@ -267,7 +266,7 @@ func run(opts ...service.Option) { log.Fatal(err) } defer resp.Body.Close() - b, err := ioutil.ReadAll(resp.Body) + b, err := io.ReadAll(resp.Body) if err != nil { log.Fatal(err) } diff --git a/registry/mdns/mdns.go b/registry/mdns/mdns.go index 9b6a5f5..7f33abf 100644 --- a/registry/mdns/mdns.go +++ b/registry/mdns/mdns.go @@ -7,7 +7,7 @@ import ( "encoding/hex" "encoding/json" "fmt" - "io/ioutil" + "io" "net" "strconv" "strings" @@ -122,7 +122,7 @@ func decode(record []string) (*mdnsTxt, error) { return nil, err } - rbuf, err := ioutil.ReadAll(zr) + rbuf, err := io.ReadAll(zr) if err != nil { return nil, err } diff --git a/service/options.go b/service/options.go index e8da55a..f693b2c 100644 --- a/service/options.go +++ b/service/options.go @@ -6,8 +6,8 @@ import ( "crypto/x509" "embed" "fmt" - "io/ioutil" "net" + "os" "strings" "github.com/grpc-ecosystem/grpc-gateway/v2/runtime" @@ -533,7 +533,7 @@ func (o *options) parseTLSConfig() error { } return nil } - caCert, err := ioutil.ReadFile(o.caCert) + caCert, err := os.ReadFile(o.caCert) if err != nil { return err }