Skip to content

Commit

Permalink
Replace io/ioutil
Browse files Browse the repository at this point in the history
It was deprecated in Go 1.16 and its functions moved elsewhere.
  • Loading branch information
bgilbert committed Aug 10, 2022
1 parent ec866dc commit 151c506
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 10 deletions.
4 changes: 2 additions & 2 deletions fedoracoreos/fcos.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ package fedoracoreos
import (
"encoding/json"
"fmt"
"io/ioutil"
"io"
"net/http"
"net/url"

Expand Down Expand Up @@ -35,7 +35,7 @@ func getStream(u url.URL) (*stream.Stream, error) {
if err != nil {
return nil, err
}
body, err := ioutil.ReadAll(resp.Body)
body, err := io.ReadAll(resp.Body)
resp.Body.Close()
if err != nil {
return nil, err
Expand Down
8 changes: 4 additions & 4 deletions release/release_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ package release

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

Expand All @@ -15,7 +15,7 @@ const (
)

func TestParseFCR(t *testing.T) {
d, err := ioutil.ReadFile("fixtures/fcos-release.json")
d, err := os.ReadFile("fixtures/fcos-release.json")
assert.Nil(t, err)
release := Release{}
err = json.Unmarshal(d, &release)
Expand All @@ -25,7 +25,7 @@ func TestParseFCR(t *testing.T) {
}

func TestParseFCRIndex(t *testing.T) {
d, err := ioutil.ReadFile("fixtures/fcos-releases.json")
d, err := os.ReadFile("fixtures/fcos-releases.json")
assert.Nil(t, err)
idx := Index{}
err = json.Unmarshal(d, &idx)
Expand All @@ -38,7 +38,7 @@ func TestParseFCRIndex(t *testing.T) {
}

func TestTranslate(t *testing.T) {
d, err := ioutil.ReadFile("fixtures/fcos-release.json")
d, err := os.ReadFile("fixtures/fcos-release.json")
assert.Nil(t, err)
rel := Release{}
err = json.Unmarshal(d, &rel)
Expand Down
3 changes: 1 addition & 2 deletions stream/artifact_utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import (
"crypto/sha256"
"fmt"
"io"
"io/ioutil"
"net/http"
"net/url"
"os"
Expand Down Expand Up @@ -63,7 +62,7 @@ func (a *Artifact) Download(destdir string) (string, error) {
return "", err
}
destfile := filepath.Join(destdir, name)
w, err := ioutil.TempFile(destdir, ".coreos-artifact-")
w, err := os.CreateTemp(destdir, ".coreos-artifact-")
if err != nil {
return "", err
}
Expand Down
4 changes: 2 additions & 2 deletions stream/stream_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,14 @@ package stream

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

"github.com/stretchr/testify/assert"
)

func TestParseFCS(t *testing.T) {
d, err := ioutil.ReadFile("fixtures/fcos-stream.json")
d, err := os.ReadFile("fixtures/fcos-stream.json")
assert.Nil(t, err)
stream := Stream{}
err = json.Unmarshal(d, &stream)
Expand Down

0 comments on commit 151c506

Please sign in to comment.