Skip to content

Commit

Permalink
Removed refs to deprecated io/ioutil
Browse files Browse the repository at this point in the history
  • Loading branch information
rishabhatdell committed Aug 25, 2023
1 parent c559e15 commit 6352b82
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 7 deletions.
7 changes: 3 additions & 4 deletions gonvme_tcp_fc.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ package gonvme
import (
"bufio"
"fmt"
"io/ioutil"
"os"
"os/exec"
"path"
Expand Down Expand Up @@ -99,14 +98,14 @@ func (nvme *NVMe) getFCHostInfo() ([]FCHBAInfo, error) {
for _, m := range match {

var FCHostInfo FCHBAInfo
data, err := ioutil.ReadFile(path.Join(m, "port_name"))
data, err := os.ReadFile(path.Join(m, "port_name"))
if err != nil {
log.Errorf("match: %s failed to read port_name file: %s", match, err.Error())
continue
}
FCHostInfo.PortName = strings.TrimSpace(string(data))

data, err = ioutil.ReadFile(path.Join(m, "node_name"))
data, err = os.ReadFile(path.Join(m, "node_name"))
if err != nil {
log.Errorf("match: %s failed to read node_name file: %s", match, err.Error())
continue
Expand Down Expand Up @@ -426,7 +425,7 @@ func (nvme *NVMe) getInitiators(filename string) ([]string, error) {
}

// get the contents of the initiator config file
out, err := ioutil.ReadFile(init)
out, err := os.ReadFile(init)
if err != nil {
log.Errorf("Error gathering initiator names: %v", err)
}
Expand Down
10 changes: 7 additions & 3 deletions gonvme_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,11 @@ package gonvme
import (
"encoding/json"
"fmt"
<<<<<<< HEAD
"io/ioutil"
=======
"os"
>>>>>>> Removed refs to deprecated io/ioutil
"strings"
"testing"

Expand All @@ -41,7 +45,7 @@ var (
)

func reset() {
testValuesFile, err := ioutil.ReadFile("testdata/unittest_values.json")
testValuesFile, err := os.ReadFile("testdata/unittest_values.json")
if err != nil {
log.Infof("Error Reading the file: %s ", err)
}
Expand Down Expand Up @@ -725,7 +729,7 @@ func TestSessionParserParse(t *testing.T) {
fileErrMsg := "can't read file with test data"

// test valid data
data, err := ioutil.ReadFile("testdata/session_info_valid")
data, err := os.ReadFile("testdata/session_info_valid")
if err != nil {
t.Error(fileErrMsg)
}
Expand All @@ -748,7 +752,7 @@ func TestSessionParserParse(t *testing.T) {
}

// test invalid data parsing
data, err = ioutil.ReadFile("testdata/session_info_invalid")
data, err = os.ReadFile("testdata/session_info_invalid")
if err != nil {
t.Error(fileErrMsg)
}
Expand Down

0 comments on commit 6352b82

Please sign in to comment.