From 3b9e9dceaa1c623413d1dd59a52b60dbe106212e Mon Sep 17 00:00:00 2001 From: Seth Vargo Date: Tue, 17 May 2022 15:35:02 -0400 Subject: [PATCH] Require go1.18 --- .github/workflows/unit.yml | 6 +----- actions.go | 7 ++----- actions_test.go | 14 +++++++------- go.mod | 2 +- 4 files changed, 11 insertions(+), 18 deletions(-) diff --git a/.github/workflows/unit.yml b/.github/workflows/unit.yml index e796c1d..78bccc4 100644 --- a/.github/workflows/unit.yml +++ b/.github/workflows/unit.yml @@ -39,11 +39,7 @@ jobs: - 'windows-latest' - 'macos-latest' go: - - '1.13' - - '1.14' - - '1.15' - - '1.16' - - '1.17' + - '1.18' runs-on: '${{ matrix.os }}' diff --git a/actions.go b/actions.go index fe64af0..6287c3d 100644 --- a/actions.go +++ b/actions.go @@ -23,7 +23,6 @@ import ( "encoding/json" "fmt" "io" - "io/ioutil" "net/http" "net/url" "os" @@ -41,10 +40,8 @@ const ( setOutputCmd = "set-output" saveStateCmd = "save-state" - addPathCmd = "add-path" // used when issuing the regular command - pathCmd = "path" // used when issuing the file command + pathCmd = "path" // used when issuing the file command - setEnvCmd = "set-env" // used when issuing the regular command envCmd = "env" // used when issuing the file command envCmdMsgFmt = "%s<<%s" + EOF + "%s" + EOF + "%s" // ${name}<<${delimiter}${os.EOL}${convertedVal}${os.EOL}${delimiter} envCmdDelimiter = "_GitHubActionsFileCommandDelimeter_" @@ -391,7 +388,7 @@ func (c *Action) GetIDToken(ctx context.Context, audience string) (string, error // This has moved to the io package in Go 1.16, but we still support up to Go // 1.13 for now. - body, err := ioutil.ReadAll(io.LimitReader(resp.Body, 64*1000)) + body, err := io.ReadAll(io.LimitReader(resp.Body, 64*1000)) if err != nil { return "", fmt.Errorf("failed to read response body: %w", err) } diff --git a/actions_test.go b/actions_test.go index 37b1272..acab714 100644 --- a/actions_test.go +++ b/actions_test.go @@ -18,7 +18,7 @@ import ( "bytes" "context" "fmt" - "io/ioutil" + "io" "net/http" "net/http/httptest" "os" @@ -71,7 +71,7 @@ func TestAction_IssueCommand(t *testing.T) { func TestAction_IssueFileCommand(t *testing.T) { t.Parallel() - file, err := ioutil.TempFile("", "") + file, err := os.CreateTemp("", "") if err != nil { t.Fatalf("unable to create a temp env file: %s", err) } @@ -95,7 +95,7 @@ func TestAction_IssueFileCommand(t *testing.T) { } // expect the message to be written to the env file - data, err := ioutil.ReadFile(file.Name()) + data, err := os.ReadFile(file.Name()) if err != nil { t.Errorf("unable to read temp env file: %s", err) } @@ -147,7 +147,7 @@ func TestAction_AddPath(t *testing.T) { const envGitHubPath = "GITHUB_PATH" // expect a file command to be issued when env file is set. - file, err := ioutil.TempFile("", "") + file, err := os.CreateTemp("", "") if err != nil { t.Fatalf("unable to create a temp env file: %s", err) } @@ -169,7 +169,7 @@ func TestAction_AddPath(t *testing.T) { } // expect the message to be written to the file. - data, err := ioutil.ReadAll(file) + data, err := io.ReadAll(file) if err != nil { t.Errorf("unable to read temp env file: %s", err) } @@ -234,7 +234,7 @@ func TestAction_SetEnv(t *testing.T) { // expectations for env file env commands var b bytes.Buffer - file, err := ioutil.TempFile("", "") + file, err := os.CreateTemp("", "") if err != nil { t.Fatalf("unable to create a temp env file: %s", err) } @@ -251,7 +251,7 @@ func TestAction_SetEnv(t *testing.T) { } // expect the command to be written to the file. - data, err := ioutil.ReadAll(file) + data, err := io.ReadAll(file) if err != nil { t.Errorf("unable to read temp env file: %s", err) } diff --git a/go.mod b/go.mod index 7b7e6e7..77a201f 100644 --- a/go.mod +++ b/go.mod @@ -14,4 +14,4 @@ module github.com/sethvargo/go-githubactions -go 1.13 +go 1.18