lint: remove deprecated io/util package (#2503)

As of go1.16, io/util package has been deprecated

See issue, https://github.com/golang/go/issues/42026

Signed-off-by: Rui Chen <rui@chenrui.dev>

Signed-off-by: Rui Chen <rui@chenrui.dev>
This commit is contained in:
Rui Chen
2022-09-08 13:45:00 -04:00
committed by GitHub
parent 2d7ee9dfa8
commit b5e985c158
5 changed files with 8 additions and 11 deletions

View File

@@ -3,7 +3,7 @@ package controllers
import (
"encoding/json"
"fmt"
"io/ioutil"
"io"
"net/http"
"strings"
@@ -181,7 +181,7 @@ func (a *APIController) apiParseAndValidate(r *http.Request) (*APIRequest, *comm
}
// Parse the JSON payload
bytes, err := ioutil.ReadAll(r.Body)
bytes, err := io.ReadAll(r.Body)
if err != nil {
return nil, nil, http.StatusBadRequest, fmt.Errorf("failed to read request")
}

View File

@@ -2,7 +2,6 @@ package runtime_test
import (
"fmt"
"io/ioutil"
"os"
"path/filepath"
"strings"
@@ -53,7 +52,7 @@ func TestRun_Success(t *testing.T) {
tmpDir, cleanup := TempDir(t)
defer cleanup()
planPath := filepath.Join(tmpDir, "workspace.tfplan")
err := ioutil.WriteFile(planPath, nil, 0600)
err := os.WriteFile(planPath, nil, 0600)
logger := logging.NewNoopLogger(t)
ctx := command.ProjectContext{
Log: logger,
@@ -84,7 +83,7 @@ func TestRun_AppliesCorrectProjectPlan(t *testing.T) {
tmpDir, cleanup := TempDir(t)
defer cleanup()
planPath := filepath.Join(tmpDir, "projectname-default.tfplan")
err := ioutil.WriteFile(planPath, nil, 0600)
err := os.WriteFile(planPath, nil, 0600)
logger := logging.NewNoopLogger(t)
ctx := command.ProjectContext{

View File

@@ -16,7 +16,6 @@ package events_test
import (
"encoding/json"
"fmt"
"io/ioutil"
"os"
"path/filepath"
"strings"
@@ -500,7 +499,7 @@ func TestParseGitlabMergeEvent_Update_ActionType(t *testing.T) {
for _, c := range cases {
t.Run(c.filename, func(t *testing.T) {
path := filepath.Join("testdata", c.filename)
bytes, err := ioutil.ReadFile(path)
bytes, err := os.ReadFile(path)
Ok(t, err)
var event *gitlab.MergeEvent

View File

@@ -14,7 +14,7 @@
package events_test
import (
"io/ioutil"
"os"
"testing"
"github.com/pkg/errors"
@@ -213,7 +213,7 @@ func TestCleanUpLogStreaming(t *testing.T) {
var configBucket = "configBucket"
var pullsBucketName = "pulls"
f, err := ioutil.TempFile("", "")
f, err := os.CreateTemp("", "")
if err != nil {
panic(errors.Wrap(err, "failed to create temp file"))
}

View File

@@ -17,7 +17,6 @@ import (
"compress/gzip"
"fmt"
"io"
"io/ioutil"
"os"
"path/filepath"
"strings"
@@ -427,7 +426,7 @@ func RestoreAsset(dir, name string) error {
if err != nil {
return err
}
err = ioutil.WriteFile(_filePath(dir, name), data, info.Mode())
err = os.WriteFile(_filePath(dir, name), data, info.Mode())
if err != nil {
return err
}