Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove usage of deprecated io/ioutil #341

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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'
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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))

Expand Down Expand Up @@ -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).
The full set of options can be found [here](https://godoc.org/github.com/alecthomas/kong#Option).
3 changes: 1 addition & 2 deletions config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package kong_test

import (
"encoding/json"
"io/ioutil"
"os"
"testing"

Expand Down Expand Up @@ -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)
Expand Down
5 changes: 2 additions & 3 deletions mapper.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import (
"encoding/json"
"errors"
"fmt"
"io/ioutil"
"math/bits"
"net/url"
"os"
Expand Down Expand Up @@ -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)
}
Expand All @@ -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)
}
Expand Down
5 changes: 2 additions & 3 deletions mapper_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import (
"bytes"
"encoding/json"
"fmt"
"io/ioutil"
"math"
"net/url"
"os"
Expand Down Expand Up @@ -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")
Expand All @@ -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")
Expand Down
3 changes: 1 addition & 2 deletions util_test.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package kong

import (
"io/ioutil"
"os"
"path/filepath"
"runtime"
Expand All @@ -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
Expand Down