Skip to content

Commit

Permalink
cmd: replace uses of deprecated io/ioutil
Browse files Browse the repository at this point in the history
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
  • Loading branch information
thaJeztah committed Nov 20, 2022
1 parent 45225c2 commit fc8619e
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 9 deletions.
10 changes: 5 additions & 5 deletions cmd/cfssljson/cfssljson.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,21 +7,21 @@ import (
"encoding/json"
"flag"
"fmt"
"io/ioutil"
"io"
"os"

"github.com/cloudflare/cfssl/cli/version"
)

func readFile(filespec string) ([]byte, error) {
if filespec == "-" {
return ioutil.ReadAll(os.Stdin)
return io.ReadAll(os.Stdin)
}
return ioutil.ReadFile(filespec)
return os.ReadFile(filespec)
}

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

if contents, ok := input["ocspResponse"]; ok {
//ocspResponse is base64 encoded
// ocspResponse is base64 encoded
resp, err := base64.StdEncoding.DecodeString(contents.(string))
if err != nil {
fmt.Fprintf(os.Stderr, "Failed to parse ocspResponse: %v\n", err)
Expand Down
4 changes: 2 additions & 2 deletions cmd/mkbundle/mkbundle.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,14 @@
// All certificates in the input file paths are checked for revocation and bundled together.
//
// Usage:
//
// mkbundle -f bundle_file -nw number_of_workers certificate_file_path ...
package main

import (
"crypto/x509"
"encoding/pem"
"flag"
"io/ioutil"
"os"
"path/filepath"
"sync"
Expand All @@ -32,7 +32,7 @@ func worker(paths chan string, bundler chan *x509.Certificate, pool *sync.WaitGr

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

fileData, err := ioutil.ReadFile(path)
fileData, err := os.ReadFile(path)
if err != nil {
log.Warningf("%v", err)
continue
Expand Down
4 changes: 2 additions & 2 deletions cmd/multirootca/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package main
import (
"encoding/json"
"fmt"
"io/ioutil"
"io"
"net/http"
"net/http/httputil"

Expand Down Expand Up @@ -82,7 +82,7 @@ func dispatchRequest(w http.ResponseWriter, req *http.Request) {
}

defer req.Body.Close()
body, err := ioutil.ReadAll(req.Body)
body, err := io.ReadAll(req.Body)
if err != nil {
fail(w, req, http.StatusInternalServerError, 1, err.Error(), "while reading request body")
return
Expand Down

0 comments on commit fc8619e

Please sign in to comment.