Skip to content

Commit

Permalink
refactor: replacing io/ioutil package because is deprecated
Browse files Browse the repository at this point in the history
  • Loading branch information
robsonpeixoto committed Jan 23, 2023
1 parent 6727e06 commit 3723a8b
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 12 deletions.
7 changes: 3 additions & 4 deletions client/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import (
"crypto/x509"
"errors"
"fmt"
"io/ioutil"
"math"
"net"
"os"
Expand Down Expand Up @@ -487,7 +486,7 @@ func (c *Client) loadTLS() (*tls.Config, error) {
}

if c.cfg.TLS.CACert != "" {
ca, err := ioutil.ReadFile(c.cfg.TLS.CACert)
ca, err := os.ReadFile(c.cfg.TLS.CACert)
if err != nil {
return nil, fmt.Errorf("unable to read CA file %q: %v",
c.cfg.TLS.CACert, err)
Expand All @@ -505,12 +504,12 @@ func (c *Client) loadTLS() (*tls.Config, error) {
return nil, errors.New("both client and key cert paths must be specified, but saw only one")
}

cert, err := ioutil.ReadFile(c.cfg.TLS.ClientCertPath)
cert, err := os.ReadFile(c.cfg.TLS.ClientCertPath)
if err != nil {
return nil, fmt.Errorf("unable to read client cert file %q: %v",
c.cfg.TLS.ClientCertPath, err)
}
key, err := ioutil.ReadFile(c.cfg.TLS.ClientKeyPath)
key, err := os.ReadFile(c.cfg.TLS.ClientKeyPath)
if err != nil {
return nil, fmt.Errorf("unable to read client key file %q: %v",
c.cfg.TLS.ClientKeyPath, err)
Expand Down
4 changes: 2 additions & 2 deletions commands/admin/admin.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import (
"context"
"encoding/json"
"fmt"
"io/ioutil"
"os"
"regexp"
"strconv"
"strings"
Expand Down Expand Up @@ -196,7 +196,7 @@ delete-records --json-file records.json`,
Offset int64 `json:"offset"`
}
var fileReqs []fileReq
raw, err := ioutil.ReadFile(jsonFile)
raw, err := os.ReadFile(jsonFile)
out.MaybeDie(err, "unable to read json file: %v", err)
err = json.Unmarshal(raw, &fileReqs)
out.MaybeDie(err, "unable to unmarshal json file: %v", err)
Expand Down
4 changes: 2 additions & 2 deletions commands/misc/misc.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import (
"context"
"encoding/json"
"fmt"
"io/ioutil"
"io"
"os"
"sort"
"strconv"
Expand Down Expand Up @@ -320,7 +320,7 @@ func rawCommand(cl *client.Client) *cobra.Command {
if req == nil {
out.Die("request key %d unknown", key)
}
raw, err := ioutil.ReadAll(os.Stdin)
raw, err := io.ReadAll(os.Stdin)
out.MaybeDie(err, "unable to read stdin: %v", err)
err = json.Unmarshal(raw, req)
out.MaybeDie(err, "unable to unmarshal stdin: %v", err)
Expand Down
7 changes: 3 additions & 4 deletions commands/myconfig/command.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ package myconfig

import (
"fmt"
"io/ioutil"
"os"
"path/filepath"
"strings"
Expand Down Expand Up @@ -183,7 +182,7 @@ default config path.
ValidArgsFunction: func(_ *cobra.Command, _ []string, _ string) ([]string, cobra.ShellCompDirective) {
defaultCfg := filepath.Base(cl.DefaultCfgPath())
dir := filepath.Dir(cl.DefaultCfgPath())
dirents, err := ioutil.ReadDir(dir)
dirents, err := os.ReadDir(dir)
if err != nil {
return nil, cobra.ShellCompDirectiveError
}
Expand Down Expand Up @@ -215,7 +214,7 @@ default config path.
}
}

dirents, err := ioutil.ReadDir(dir)
dirents, err := os.ReadDir(dir)
out.MaybeDie(err, "unable to read config dir %q: %v", dir, err)

use := args[0]
Expand Down Expand Up @@ -332,7 +331,7 @@ func listCommand(cl *client.Client) *cobra.Command {
}

dir := filepath.Dir(cl.DefaultCfgPath())
dirents, err := ioutil.ReadDir(dir)
dirents, err := os.ReadDir(dir)
out.MaybeDie(err, "unable to read config dir %q: %v", dir, err)
for _, dirent := range dirents {
name := dirent.Name()
Expand Down

0 comments on commit 3723a8b

Please sign in to comment.