Skip to content

Commit fc8619e

Browse files
committed
cmd: replace uses of deprecated io/ioutil
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
1 parent 45225c2 commit fc8619e

File tree

3 files changed

+9
-9
lines changed

3 files changed

+9
-9
lines changed

cmd/cfssljson/cfssljson.go

+5-5
Original file line numberDiff line numberDiff line change
@@ -7,21 +7,21 @@ import (
77
"encoding/json"
88
"flag"
99
"fmt"
10-
"io/ioutil"
10+
"io"
1111
"os"
1212

1313
"github.com/cloudflare/cfssl/cli/version"
1414
)
1515

1616
func readFile(filespec string) ([]byte, error) {
1717
if filespec == "-" {
18-
return ioutil.ReadAll(os.Stdin)
18+
return io.ReadAll(os.Stdin)
1919
}
20-
return ioutil.ReadFile(filespec)
20+
return os.ReadFile(filespec)
2121
}
2222

2323
func writeFile(filespec, contents string, perms os.FileMode) {
24-
err := ioutil.WriteFile(filespec, []byte(contents), perms)
24+
err := os.WriteFile(filespec, []byte(contents), perms)
2525
if err != nil {
2626
fmt.Fprintf(os.Stderr, "%v\n", err)
2727
os.Exit(1)
@@ -184,7 +184,7 @@ func main() {
184184
}
185185

186186
if contents, ok := input["ocspResponse"]; ok {
187-
//ocspResponse is base64 encoded
187+
// ocspResponse is base64 encoded
188188
resp, err := base64.StdEncoding.DecodeString(contents.(string))
189189
if err != nil {
190190
fmt.Fprintf(os.Stderr, "Failed to parse ocspResponse: %v\n", err)

cmd/mkbundle/mkbundle.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,14 @@
22
// All certificates in the input file paths are checked for revocation and bundled together.
33
//
44
// Usage:
5+
//
56
// mkbundle -f bundle_file -nw number_of_workers certificate_file_path ...
67
package main
78

89
import (
910
"crypto/x509"
1011
"encoding/pem"
1112
"flag"
12-
"io/ioutil"
1313
"os"
1414
"path/filepath"
1515
"sync"
@@ -32,7 +32,7 @@ func worker(paths chan string, bundler chan *x509.Certificate, pool *sync.WaitGr
3232

3333
log.Infof("Loading %s", path)
3434

35-
fileData, err := ioutil.ReadFile(path)
35+
fileData, err := os.ReadFile(path)
3636
if err != nil {
3737
log.Warningf("%v", err)
3838
continue

cmd/multirootca/api.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ package main
33
import (
44
"encoding/json"
55
"fmt"
6-
"io/ioutil"
6+
"io"
77
"net/http"
88
"net/http/httputil"
99

@@ -82,7 +82,7 @@ func dispatchRequest(w http.ResponseWriter, req *http.Request) {
8282
}
8383

8484
defer req.Body.Close()
85-
body, err := ioutil.ReadAll(req.Body)
85+
body, err := io.ReadAll(req.Body)
8686
if err != nil {
8787
fail(w, req, http.StatusInternalServerError, 1, err.Error(), "while reading request body")
8888
return

0 commit comments

Comments
 (0)