Skip to content

Commit

Permalink
lint: remove deprecated io/util package (#2503)
Browse files Browse the repository at this point in the history
As of go1.16, io/util package has been deprecated

See issue, golang/go#42026

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

Signed-off-by: Rui Chen <rui@chenrui.dev>
  • Loading branch information
chenrui333 committed Sep 8, 2022
1 parent 2d7ee9d commit b5e985c
Show file tree
Hide file tree
Showing 5 changed files with 8 additions and 11 deletions.
4 changes: 2 additions & 2 deletions server/controllers/api_controller.go
Expand Up @@ -3,7 +3,7 @@ package controllers
import (
"encoding/json"
"fmt"
"io/ioutil"
"io"
"net/http"
"strings"

Expand Down Expand Up @@ -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")
}
Expand Down
5 changes: 2 additions & 3 deletions server/core/runtime/apply_step_runner_test.go
Expand Up @@ -2,7 +2,6 @@ package runtime_test

import (
"fmt"
"io/ioutil"
"os"
"path/filepath"
"strings"
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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{
Expand Down
3 changes: 1 addition & 2 deletions server/events/event_parser_test.go
Expand Up @@ -16,7 +16,6 @@ package events_test
import (
"encoding/json"
"fmt"
"io/ioutil"
"os"
"path/filepath"
"strings"
Expand Down Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions server/events/pull_closed_executor_test.go
Expand Up @@ -14,7 +14,7 @@
package events_test

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

"github.com/pkg/errors"
Expand Down Expand Up @@ -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"))
}
Expand Down
3 changes: 1 addition & 2 deletions server/static/bindata_assetfs.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit b5e985c

Please sign in to comment.