diff --git a/.golangci.yml b/.golangci.yml index 1ee8fa6..e90edb8 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -65,4 +65,3 @@ issues: - 'bad syntax for struct tag key' - 'bad syntax for struct tag pair' - 'result .* \(error\) is always nil' - - 'package io/ioutil is deprecated' diff --git a/README.md b/README.md index 40cdbb7..2e393ed 100644 --- a/README.md +++ b/README.md @@ -329,7 +329,7 @@ var cli struct { func main() { // Debug logger going to discard. - logger := log.New(ioutil.Discard, "", log.LstdFlags) + logger := log.New(io.Discard, "", log.LstdFlags) ctx := kong.Parse(&cli, kong.Bind(logger)) @@ -703,4 +703,4 @@ See the [section on hooks](#hooks-beforeresolve-beforeapply-afterapply-and-the-b ### Other options -The full set of options can be found [here](https://godoc.org/github.com/alecthomas/kong#Option). \ No newline at end of file +The full set of options can be found [here](https://godoc.org/github.com/alecthomas/kong#Option). diff --git a/config_test.go b/config_test.go index 0d7f2cc..9925f60 100644 --- a/config_test.go +++ b/config_test.go @@ -2,7 +2,6 @@ package kong_test import ( "encoding/json" - "io/ioutil" "os" "testing" @@ -45,7 +44,7 @@ func TestConfigValidation(t *testing.T) { func makeConfig(t *testing.T, config interface{}) (path string, cleanup func()) { t.Helper() - w, err := ioutil.TempFile("", "") + w, err := os.CreateTemp("", "") assert.NoError(t, err) defer w.Close() // nolint: gosec err = json.NewEncoder(w).Encode(config) diff --git a/mapper.go b/mapper.go index 65f9814..a99bcb9 100644 --- a/mapper.go +++ b/mapper.go @@ -5,7 +5,6 @@ import ( "encoding/json" "errors" "fmt" - "io/ioutil" "math/bits" "net/url" "os" @@ -813,7 +812,7 @@ func (f *NamedFileContentFlag) Decode(ctx *DecodeContext) error { // nolint: rev return nil } filename = ExpandPath(filename) - data, err := ioutil.ReadFile(filename) // nolint: gosec + data, err := os.ReadFile(filename) // nolint: gosec if err != nil { return fmt.Errorf("failed to open %q: %v", filename, err) } @@ -837,7 +836,7 @@ func (f *FileContentFlag) Decode(ctx *DecodeContext) error { // nolint: revive return nil } filename = ExpandPath(filename) - data, err := ioutil.ReadFile(filename) // nolint: gosec + data, err := os.ReadFile(filename) // nolint: gosec if err != nil { return fmt.Errorf("failed to open %q: %v", filename, err) } diff --git a/mapper_test.go b/mapper_test.go index e86fed7..dd2383c 100644 --- a/mapper_test.go +++ b/mapper_test.go @@ -4,7 +4,6 @@ import ( "bytes" "encoding/json" "fmt" - "io/ioutil" "math" "net/url" "os" @@ -269,7 +268,7 @@ func TestFileContentFlag(t *testing.T) { var cli struct { File kong.FileContentFlag } - f, err := ioutil.TempFile("", "") + f, err := os.CreateTemp("", "") assert.NoError(t, err) defer os.Remove(f.Name()) fmt.Fprint(f, "hello world") @@ -283,7 +282,7 @@ func TestNamedFileContentFlag(t *testing.T) { var cli struct { File kong.NamedFileContentFlag } - f, err := ioutil.TempFile("", "") + f, err := os.CreateTemp("", "") assert.NoError(t, err) defer os.Remove(f.Name()) fmt.Fprint(f, "hello world") diff --git a/util_test.go b/util_test.go index 2457ed8..5a5cb3e 100644 --- a/util_test.go +++ b/util_test.go @@ -1,7 +1,6 @@ package kong import ( - "io/ioutil" "os" "path/filepath" "runtime" @@ -17,7 +16,7 @@ func TestConfigFlag(t *testing.T) { Flag string } - w, err := ioutil.TempFile("", "") + w, err := os.CreateTemp("", "") assert.NoError(t, err) defer os.Remove(w.Name()) w.WriteString(`{"flag": "hello world"}`) // nolint: errcheck