Skip to content

Commit 8c24f35

Browse files
authored
fix: bump linter 1.48.0 and remplace "io/ioutil". (#2447)
1 parent 48fa817 commit 8c24f35

36 files changed

+74
-100
lines changed

.github/workflows/golangci-lint.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,4 +11,4 @@ jobs:
1111
uses: golangci/golangci-lint-action@v2
1212
with:
1313
# Required: the version of golangci-lint is required and must be specified without patch version: we always use the latest patch version.
14-
version: v1.45.2
14+
version: v1.48.0

Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
FROM golang:1.15-alpine as builder
1+
FROM golang:1.19-alpine as builder
22

33
ENV BUILD_IN_DOCKER true
44
ARG VERSION

internal/account/account.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import (
44
"context"
55
"encoding/json"
66
"fmt"
7-
"io/ioutil"
7+
"io"
88
"net/http"
99
)
1010

@@ -48,7 +48,7 @@ func GetAPIKey(ctx context.Context, secretKey string) (*Token, error) {
4848
}
4949

5050
token := &LoginResponse{}
51-
b, err := ioutil.ReadAll(resp.Body)
51+
b, err := io.ReadAll(resp.Body)
5252
if err != nil {
5353
return nil, err
5454
}

internal/args/marshal.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -94,10 +94,10 @@ func RegisterMarshalFunc(i interface{}, marshalFunc MarshalFunc) {
9494
// It will take care of pointers resolution, nested structs, etc.
9595
//
9696
// If this function is called with:
97-
// - a marshalable value: [ "${keys.join(.)}=${marshaledValue}" ]
98-
// - a go struct: [ "${keys.join(.)}.field1=${marshaledField1}", ... ]
99-
// - a go map: [ "${keys.join(.)}.key1=${marshaledValue1}", ... ]
100-
// - a go slice: [ "${keys.join(.)}.0=${marshaledValue0}", ... ]
97+
// - a marshal-able value: [ "${keys.join(.)}=${marshaledValue}" ]
98+
// - a go struct: [ "${keys.join(.)}.field1=${marshaledField1}", ... ]
99+
// - a go map: [ "${keys.join(.)}.key1=${marshaledValue1}", ... ]
100+
// - a go slice: [ "${keys.join(.)}.0=${marshaledValue0}", ... ]
101101
//
102102
// src: the value to marshal
103103
// keys: the parent keys used by recursion (nil on first level)

internal/core/arg_file_content.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import (
44
"bytes"
55
"fmt"
66
"io"
7-
"io/ioutil"
7+
"os"
88
"reflect"
99
"strings"
1010

@@ -27,13 +27,13 @@ func loadArgsFileContent(cmd *Command, cmdArgs interface{}) error {
2727
for _, v := range fieldValues {
2828
switch i := v.Interface().(type) {
2929
case io.Reader:
30-
b, err := ioutil.ReadAll(i)
30+
b, err := io.ReadAll(i)
3131
if err != nil {
3232
return fmt.Errorf("could not read argument: %s", err)
3333
}
3434

3535
if strings.HasPrefix(string(b), "@") {
36-
content, err := ioutil.ReadFile(string(b)[1:])
36+
content, err := os.ReadFile(string(b)[1:])
3737
if err != nil {
3838
return fmt.Errorf("could not open requested file: %s", err)
3939
}
@@ -42,15 +42,15 @@ func loadArgsFileContent(cmd *Command, cmdArgs interface{}) error {
4242
}
4343
case *string:
4444
if strings.HasPrefix(*i, "@") {
45-
content, err := ioutil.ReadFile((*i)[1:])
45+
content, err := os.ReadFile((*i)[1:])
4646
if err != nil {
4747
return fmt.Errorf("could not open requested file: %s", err)
4848
}
4949
v.SetString(string(content))
5050
}
5151
case string:
5252
if strings.HasPrefix(i, "@") {
53-
content, err := ioutil.ReadFile(i[1:])
53+
content, err := os.ReadFile(i[1:])
5454
if err != nil {
5555
return fmt.Errorf("could not open requested file: %s", err)
5656
}

internal/core/autocomplete.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ func NewAutoCompleteCommandNode() *AutoCompleteNode {
112112
}
113113
}
114114

115-
// NewArgAutoCompleteNode creates a new node corresponding to a command argument.
115+
// NewAutoCompleteArgNode creates a new node corresponding to a command argument.
116116
// These nodes are leaf nodes.
117117
func NewAutoCompleteArgNode(cmd *Command, argSpec *ArgSpec) *AutoCompleteNode {
118118
return &AutoCompleteNode{
@@ -123,11 +123,11 @@ func NewAutoCompleteArgNode(cmd *Command, argSpec *ArgSpec) *AutoCompleteNode {
123123
}
124124
}
125125

126-
// NewFlagAutoCompleteNode returns a node representing a Flag.
126+
// NewAutoCompleteFlagNode returns a node representing a Flag.
127127
// It creates the children node with possible values if they exist.
128128
// It sets parent.children as children of the lowest nodes:
129-
// the lowest node is the flag if it has no possible value ;
130-
// or the lowest nodes are the possible values if the exist.
129+
// the lowest node is the flag if it has no possible value ;
130+
// or the lowest nodes are the possible values if the exist.
131131
func NewAutoCompleteFlagNode(parent *AutoCompleteNode, flagSpec *FlagSpec) *AutoCompleteNode {
132132
node := &AutoCompleteNode{
133133
Children: make(map[string]*AutoCompleteNode),

internal/core/build_info.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import (
44
"context"
55
"encoding/json"
66
"fmt"
7-
"io/ioutil"
7+
"io"
88
"net/http"
99
"os"
1010
"path/filepath"
@@ -111,7 +111,7 @@ func getLatestVersion(client *http.Client) (*version.Version, error) {
111111
if err != nil {
112112
return nil, err
113113
}
114-
body, err := ioutil.ReadAll(resp.Body)
114+
body, err := io.ReadAll(resp.Body)
115115
if err != nil {
116116
return nil, err
117117
}

internal/core/command_interceptor.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ package core
33
import (
44
"context"
55
"fmt"
6-
"io/ioutil"
6+
"io"
77
"strings"
88

99
"github.com/scaleway/scaleway-sdk-go/scw"
@@ -127,7 +127,7 @@ func sdkStdTypeInterceptor(ctx context.Context, args interface{}, runner Command
127127
switch sdkValue := res.(type) {
128128
case *scw.File:
129129
ExtractLogger(ctx).Debug("Intercepting scw.File type, rendering as string")
130-
fileContent, err := ioutil.ReadAll(sdkValue.Content)
130+
fileContent, err := io.ReadAll(sdkValue.Content)
131131
if err != nil {
132132
return nil, err
133133
}

internal/core/testing.go

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ import (
66
"flag"
77
"fmt"
88
"io"
9-
"io/ioutil"
109
"net/http"
1110
"os"
1211
"os/exec"
@@ -330,7 +329,7 @@ func Test(config *TestConfig) func(t *testing.T) {
330329
}
331330

332331
if config.TmpHomeDir {
333-
dir, err := ioutil.TempDir(os.TempDir(), "scw")
332+
dir, err := os.MkdirTemp(os.TempDir(), "scw")
334333
require.NoError(t, err)
335334
defer func() {
336335
err = os.RemoveAll(dir)
@@ -582,10 +581,10 @@ func TestCheckGolden() TestCheck {
582581
// In order to avoid diff in goldens we set all timestamp to the same date
583582
if *UpdateGoldens {
584583
require.NoError(t, os.MkdirAll(path.Dir(goldenPath), 0755))
585-
require.NoError(t, ioutil.WriteFile(goldenPath, []byte(actual), 0644)) //nolint:gosec
584+
require.NoError(t, os.WriteFile(goldenPath, []byte(actual), 0644)) //nolint:gosec
586585
}
587586

588-
expected, err := ioutil.ReadFile(goldenPath)
587+
expected, err := os.ReadFile(goldenPath)
589588
require.NoError(t, err, "expected to find golden file %s", goldenPath)
590589
assert.Equal(t, string(expected), actual)
591590
}

internal/docgen/docgen.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ package docgen
33
import (
44
"bytes"
55
"fmt"
6-
"io/ioutil"
6+
"os"
77
"path"
88
"regexp"
99
"strings"
@@ -29,7 +29,7 @@ type tplResource struct {
2929

3030
const ansi = "[\u001B\u009B][[\\]()#;?]*(?:(?:(?:[a-zA-Z\\d]*(?:;[a-zA-Z\\d]*)*)?\u0007)|(?:(?:\\d{1,4}(?:;\\d{0,4})*)?[\\dA-PRZcf-ntqry=><~]))"
3131

32-
// Generate markdown documentation for a given list of commands
32+
// GenerateDocs generates markdown documentation for a given list of commands
3333
func GenerateDocs(commands *core.Commands, outDir string) error {
3434
// Prepare data that will be sent to template engine
3535
data := &tplData{
@@ -77,7 +77,7 @@ func GenerateDocs(commands *core.Commands, outDir string) error {
7777
if err != nil {
7878
return err
7979
}
80-
err = ioutil.WriteFile(path.Join(outDir, name+".md"), []byte(namespaceDoc), 0600)
80+
err = os.WriteFile(path.Join(outDir, name+".md"), []byte(namespaceDoc), 0600)
8181
if err != nil {
8282
return err
8383
}

0 commit comments

Comments
 (0)