Skip to content

Commit fcba8a5

Browse files
author
wafuwafu13
committed
lint: remove io/ioutil
1 parent 6645426 commit fcba8a5

27 files changed

+83
-88
lines changed

cfn/event_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ package cfn
44

55
import (
66
"encoding/json"
7-
"io/ioutil" //nolint: staticcheck
7+
"os"
88
"testing"
99

1010
"github.com/aws/aws-lambda-go/events/test"
@@ -13,7 +13,7 @@ import (
1313
func TestCloudFormationEventMarshaling(t *testing.T) {
1414

1515
// read json from file
16-
inputJSON, err := ioutil.ReadFile("./testdata/cloudformation-event.json")
16+
inputJSON, err := os.ReadFile("./testdata/cloudformation-event.json")
1717
if err != nil {
1818
t.Errorf("could not open test file. details: %v", err)
1919
}

cfn/response.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import (
66
"bytes"
77
"encoding/json"
88
"fmt"
9-
"io/ioutil" //nolint: staticcheck
9+
"io"
1010
"log"
1111
"net/http"
1212
)
@@ -67,7 +67,7 @@ func (r *Response) sendWith(client httpClient) error {
6767
return err
6868
}
6969

70-
body, err = ioutil.ReadAll(res.Body)
70+
body, err = io.ReadAll(res.Body)
7171
if err != nil {
7272
return err
7373
}

cfn/wrap_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import (
77
"context"
88
"encoding/json"
99
"errors"
10-
"io/ioutil" //nolint: staticcheck
10+
"io"
1111
"net/http"
1212
"testing"
1313

@@ -151,7 +151,7 @@ func TestWrappedSendFailure(t *testing.T) {
151151
func extractResponseBody(t *testing.T, req *http.Request) Response {
152152
assert.NotContains(t, req.Header, "Content-Type")
153153

154-
body, err := ioutil.ReadAll(req.Body)
154+
body, err := io.ReadAll(req.Body)
155155
assert.NoError(t, err)
156156
var response Response
157157
err = json.Unmarshal(body, &response)

cmd/build-lambda-zip/main.go

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,7 @@ import (
66
"archive/zip"
77
"flag"
88
"fmt"
9-
"io/ioutil" //nolint: staticcheck
10-
"log"
9+
"log"
1110
"os"
1211
"path/filepath"
1312
)
@@ -82,7 +81,7 @@ func compressExeAndArgs(outZipPath string, exePath string, args []string) error
8281

8382
zipWriter := zip.NewWriter(zipFile)
8483
defer zipWriter.Close()
85-
data, err := ioutil.ReadFile(exePath)
84+
data, err := os.ReadFile(exePath)
8685
if err != nil {
8786
return err
8887
}
@@ -97,7 +96,7 @@ func compressExeAndArgs(outZipPath string, exePath string, args []string) error
9796
if err != nil {
9897
return err
9998
}
100-
data, err := ioutil.ReadFile(arg)
99+
data, err := os.ReadFile(arg)
101100
if err != nil {
102101
return err
103102
}

cmd/build-lambda-zip/main_test.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ package main
55
import (
66
"archive/zip"
77
"fmt"
8-
"io/ioutil" //nolint: staticcheck
8+
"io"
99
"os"
1010
"os/exec"
1111
"path"
@@ -34,7 +34,7 @@ func TestSizes(t *testing.T) {
3434
}
3535
testDir, err := os.Getwd()
3636
require.NoError(t, err)
37-
tempDir, err := ioutil.TempDir("/tmp", "build-lambda-zip")
37+
tempDir, err := os.MkdirTemp("/tmp", "build-lambda-zip")
3838
require.NoError(t, err)
3939
for _, test := range cases {
4040
require.NoError(t, os.Chdir(testDir))
@@ -66,7 +66,7 @@ func TestSizes(t *testing.T) {
6666
}
6767

6868
func TestCompressExeAndArgs(t *testing.T) {
69-
tempDir, err := ioutil.TempDir("/tmp", "build-lambda-zip")
69+
tempDir, err := os.MkdirTemp("/tmp", "build-lambda-zip")
7070
require.NoError(t, err)
7171
defer os.RemoveAll(tempDir)
7272

@@ -117,7 +117,7 @@ func TestCompressExeAndArgs(t *testing.T) {
117117
link, err := bootstrap.Open()
118118
require.NoError(t, err)
119119
defer link.Close()
120-
linkTarget, err := ioutil.ReadAll(link)
120+
linkTarget, err := io.ReadAll(link)
121121
require.NoError(t, err)
122122
assert.Equal(t, filepath.Base(filePaths[0]), string(linkTarget))
123123
})
@@ -148,7 +148,7 @@ func TestCompressExeAndArgs(t *testing.T) {
148148
f, err := zf.Open()
149149
require.NoError(t, err)
150150
defer f.Close()
151-
content, err := ioutil.ReadAll(f)
151+
content, err := io.ReadAll(f)
152152
require.NoError(t, err)
153153
assert.Equal(t, fmt.Sprintf("Hello file %d!", expectedIndex), string(content), "in file: %s", zf.Name)
154154
expectedIndex++

events/alb_test.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ package events
22

33
import (
44
"encoding/json"
5-
"io/ioutil" //nolint: staticcheck
5+
"os"
66
"testing"
77

88
"github.com/aws/aws-lambda-go/events/test"
@@ -16,7 +16,7 @@ func TestALBTargetRequestMarshaling(t *testing.T) {
1616

1717
for _, filename := range inputFiles {
1818
// read json from file
19-
inputJSON, err := ioutil.ReadFile(filename)
19+
inputJSON, err := os.ReadFile(filename)
2020
if err != nil {
2121
t.Errorf("could not open test file. details: %v", err)
2222
}
@@ -43,7 +43,7 @@ func TestALBTargetRequestMalformedJson(t *testing.T) {
4343
func TestALBTargetResponseMarshaling(t *testing.T) {
4444

4545
// read json from file
46-
inputJSON, err := ioutil.ReadFile("./testdata/alb-lambda-target-response.json")
46+
inputJSON, err := os.ReadFile("./testdata/alb-lambda-target-response.json")
4747
if err != nil {
4848
t.Errorf("could not open test file. details: %v", err)
4949
}

events/apigw_test.go

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@ package events
44

55
import (
66
"encoding/json"
7-
"io/ioutil" //nolint: staticcheck
87
"testing"
8+
"os"
99

1010
"github.com/aws/aws-lambda-go/events/test"
1111
"github.com/stretchr/testify/assert"
@@ -14,7 +14,7 @@ import (
1414
func TestApiGatewayRequestMarshaling(t *testing.T) {
1515

1616
// read json from file
17-
inputJSON, err := ioutil.ReadFile("./testdata/apigw-request.json")
17+
inputJSON, err := os.ReadFile("./testdata/apigw-request.json")
1818
if err != nil {
1919
t.Errorf("could not open test file. details: %v", err)
2020
}
@@ -49,7 +49,7 @@ func TestApiGatewayRequestMalformedJson(t *testing.T) {
4949
func TestApiGatewayResponseMarshaling(t *testing.T) {
5050

5151
// read json from file
52-
inputJSON, err := ioutil.ReadFile("./testdata/apigw-response.json")
52+
inputJSON, err := os.ReadFile("./testdata/apigw-response.json")
5353
if err != nil {
5454
t.Errorf("could not open test file. details: %v", err)
5555
}
@@ -76,7 +76,7 @@ func TestApiGatewayResponseMalformedJson(t *testing.T) {
7676
func TestApiGatewayCustomAuthorizerRequestMarshaling(t *testing.T) {
7777

7878
// read json from file
79-
inputJSON, err := ioutil.ReadFile("./testdata/apigw-custom-auth-request.json")
79+
inputJSON, err := os.ReadFile("./testdata/apigw-custom-auth-request.json")
8080
if err != nil {
8181
t.Errorf("could not open test file. details: %v", err)
8282
}
@@ -99,7 +99,7 @@ func TestApiGatewayCustomAuthorizerRequestMarshaling(t *testing.T) {
9999
func TestApiGatewayCustomAuthorizerRequestTypeRequestMarshaling(t *testing.T) {
100100

101101
// read json from file
102-
inputJSON, err := ioutil.ReadFile("./testdata/apigw-custom-auth-request-type-request.json")
102+
inputJSON, err := os.ReadFile("./testdata/apigw-custom-auth-request-type-request.json")
103103
if err != nil {
104104
t.Errorf("could not open test file. details: %v", err)
105105
}
@@ -130,7 +130,7 @@ func TestApiGatewayCustomAuthorizerRequestTypeRequestMalformedJson(t *testing.T)
130130
func TestApiGatewayWebsocketRequestMarshaling(t *testing.T) {
131131

132132
// read json from file
133-
inputJSON, err := ioutil.ReadFile("./testdata/apigw-websocket-request.json")
133+
inputJSON, err := os.ReadFile("./testdata/apigw-websocket-request.json")
134134
if err != nil {
135135
t.Errorf("could not open test file. details: %v", err)
136136
}
@@ -157,7 +157,7 @@ func TestApiGatewayWebsocketRequestMalformedJson(t *testing.T) {
157157
func TestApiGatewayCustomAuthorizerResponseMarshaling(t *testing.T) {
158158

159159
// read json from file
160-
inputJSON, err := ioutil.ReadFile("./testdata/apigw-custom-auth-response.json")
160+
inputJSON, err := os.ReadFile("./testdata/apigw-custom-auth-response.json")
161161
if err != nil {
162162
t.Errorf("could not open test file. details: %v", err)
163163
}
@@ -245,7 +245,7 @@ func TestApiGatewayCustomAuthorizerResponseMalformedJson(t *testing.T) {
245245
func TestApiGatewayRestApiOpenApiRequestMarshaling(t *testing.T) {
246246

247247
// read json from file
248-
inputJSON, err := ioutil.ReadFile("./testdata/apigw-restapi-openapi-request.json")
248+
inputJSON, err := os.ReadFile("./testdata/apigw-restapi-openapi-request.json")
249249
if err != nil {
250250
t.Errorf("could not open test file. details: %v", err)
251251
}
@@ -274,7 +274,7 @@ func TestApiGatewayRestApiOpenApiRequestMarshaling(t *testing.T) {
274274
func TestApiGatewayV2HTTPRequestJWTAuthorizerMarshaling(t *testing.T) {
275275

276276
// read json from file
277-
inputJSON, err := ioutil.ReadFile("./testdata/apigw-v2-request-jwt-authorizer.json")
277+
inputJSON, err := os.ReadFile("./testdata/apigw-v2-request-jwt-authorizer.json")
278278
if err != nil {
279279
t.Errorf("could not open test file. details: %v", err)
280280
}
@@ -309,7 +309,7 @@ func TestApiGatewayV2HTTPRequestJWTAuthorizerMarshaling(t *testing.T) {
309309
func TestApiGatewayV2HTTPRequestLambdaAuthorizerMarshaling(t *testing.T) {
310310

311311
// read json from file
312-
inputJSON, err := ioutil.ReadFile("./testdata/apigw-v2-request-lambda-authorizer.json")
312+
inputJSON, err := os.ReadFile("./testdata/apigw-v2-request-lambda-authorizer.json")
313313
if err != nil {
314314
t.Errorf("could not open test file. details: %v", err)
315315
}
@@ -344,7 +344,7 @@ func TestApiGatewayV2HTTPRequestLambdaAuthorizerMarshaling(t *testing.T) {
344344
func TestApiGatewayV2HTTPRequestIAMMarshaling(t *testing.T) {
345345

346346
// read json from file
347-
inputJSON, err := ioutil.ReadFile("./testdata/apigw-v2-request-iam.json")
347+
inputJSON, err := os.ReadFile("./testdata/apigw-v2-request-iam.json")
348348
if err != nil {
349349
t.Errorf("could not open test file. details: %v", err)
350350
}
@@ -403,7 +403,7 @@ func TestApiGatewayV2HTTPRequestIAMMarshaling(t *testing.T) {
403403
func TestApiGatewayV2HTTPRequestNoAuthorizerMarshaling(t *testing.T) {
404404

405405
// read json from file
406-
inputJSON, err := ioutil.ReadFile("./testdata/apigw-v2-request-no-authorizer.json")
406+
inputJSON, err := os.ReadFile("./testdata/apigw-v2-request-no-authorizer.json")
407407
if err != nil {
408408
t.Errorf("could not open test file. details: %v", err)
409409
}
@@ -436,7 +436,7 @@ func TestApiGatewayV2HTTPRequestNoAuthorizerMarshaling(t *testing.T) {
436436
}
437437

438438
func TestApiGatewayV2CustomAuthorizerV1RequestMarshaling(t *testing.T) {
439-
inputJSON, err := ioutil.ReadFile("./testdata/apigw-v2-custom-authorizer-v1-request.json")
439+
inputJSON, err := os.ReadFile("./testdata/apigw-v2-custom-authorizer-v1-request.json")
440440
if err != nil {
441441
t.Errorf("could not open test file. details: %v", err)
442442
}
@@ -457,7 +457,7 @@ func TestApiGatewayV2CustomAuthorizerV1RequestMarshaling(t *testing.T) {
457457
}
458458

459459
func TestApiGatewayV2CustomAuthorizerV2RequestMarshaling(t *testing.T) {
460-
inputJSON, err := ioutil.ReadFile("./testdata/apigw-v2-custom-authorizer-v2-request.json")
460+
inputJSON, err := os.ReadFile("./testdata/apigw-v2-custom-authorizer-v2-request.json")
461461
if err != nil {
462462
t.Errorf("could not open test file. details: %v", err)
463463
}

events/appsync_test.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,15 @@ package events
22

33
import (
44
"encoding/json"
5-
"io/ioutil" //nolint: staticcheck
5+
"os"
66
"testing"
77

88
"github.com/aws/aws-lambda-go/events/test"
99
"github.com/stretchr/testify/assert"
1010
)
1111

1212
func TestAppSyncIdentity_IAM(t *testing.T) {
13-
inputJSON, err := ioutil.ReadFile("./testdata/appsync-identity-iam.json")
13+
inputJSON, err := os.ReadFile("./testdata/appsync-identity-iam.json")
1414
if err != nil {
1515
t.Errorf("could not open test file. details: %v", err)
1616
}
@@ -29,7 +29,7 @@ func TestAppSyncIdentity_IAM(t *testing.T) {
2929
}
3030

3131
func TestAppSyncIdentity_Cognito(t *testing.T) {
32-
inputJSON, err := ioutil.ReadFile("./testdata/appsync-identity-cognito.json")
32+
inputJSON, err := os.ReadFile("./testdata/appsync-identity-cognito.json")
3333
if err != nil {
3434
t.Errorf("could not open test file. details: %v", err)
3535
}
@@ -48,7 +48,7 @@ func TestAppSyncIdentity_Cognito(t *testing.T) {
4848
}
4949

5050
func TestAppSyncLambdaAuthorizerRequestMarshalling(t *testing.T) {
51-
inputJSON, err := ioutil.ReadFile("./testdata/appsync-lambda-auth-request.json")
51+
inputJSON, err := os.ReadFile("./testdata/appsync-lambda-auth-request.json")
5252
if err != nil {
5353
t.Errorf("could not open test file. details: %v", err)
5454
}
@@ -71,7 +71,7 @@ func TestAppSyncLambdaAuthorizerRequestMalformedJson(t *testing.T) {
7171
}
7272

7373
func TestAppSyncLambdaAuthorizerResponseMarshalling(t *testing.T) {
74-
inputJSON, err := ioutil.ReadFile("./testdata/appsync-lambda-auth-response.json")
74+
inputJSON, err := os.ReadFile("./testdata/appsync-lambda-auth-response.json")
7575
if err != nil {
7676
t.Errorf("could not open test file. details: %v", err)
7777
}

events/clientvpn_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ package events
22

33
import (
44
"encoding/json"
5-
"io/ioutil" //nolint: staticcheck
5+
"os"
66
"testing"
77

88
"github.com/aws/aws-lambda-go/events/test"
@@ -11,7 +11,7 @@ import (
1111

1212
func TestClientVPNConnectionHandlerRequestMarshaling(t *testing.T) {
1313
// read json from file
14-
inputJSON, err := ioutil.ReadFile("./testdata/clientvpn-connectionhandler-request.json")
14+
inputJSON, err := os.ReadFile("./testdata/clientvpn-connectionhandler-request.json")
1515
if err != nil {
1616
t.Errorf("could not open test file. details: %v", err)
1717
}

events/codebuild_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ package events
22

33
import (
44
"encoding/json"
5-
"io/ioutil" //nolint: staticcheck
5+
"os"
66
"testing"
77
"time"
88

@@ -301,7 +301,7 @@ func TestUnmarshalCodeBuildEvent(t *testing.T) {
301301
}
302302

303303
for _, testcase := range tests {
304-
data, err := ioutil.ReadFile(testcase.input)
304+
data, err := os.ReadFile(testcase.input)
305305
require.NoError(t, err)
306306

307307
var actual CodeBuildEvent

events/codedeploy_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ package events
33
import (
44
"encoding/json"
55
"github.com/stretchr/testify/require"
6-
"io/ioutil" //nolint: staticcheck
6+
"os"
77
"testing"
88
"time"
99
)
@@ -67,7 +67,7 @@ func TestUnmarshalCodeDeployEvent(t *testing.T) {
6767
}
6868

6969
for _, testcase := range tests {
70-
data, err := ioutil.ReadFile(testcase.input)
70+
data, err := os.ReadFile(testcase.input)
7171
require.NoError(t, err)
7272

7373
var actual CodeDeployEvent

events/codepipeline_cloudwatch_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ package events
33
import (
44
"encoding/json"
55
"github.com/stretchr/testify/require"
6-
"io/ioutil" //nolint: staticcheck
6+
"os"
77
"testing"
88
"time"
99
)
@@ -88,7 +88,7 @@ func TestUnmarshalCodePipelineEvent(t *testing.T) {
8888
}
8989

9090
for _, testcase := range tests {
91-
data, err := ioutil.ReadFile(testcase.input)
91+
data, err := os.ReadFile(testcase.input)
9292
require.NoError(t, err)
9393

9494
var actual CodePipelineCloudWatchEvent

0 commit comments

Comments
 (0)