Skip to content

Commit 6ba20c8

Browse files
authored
Fix various lints (google#1507)
* Replace interface{} with any * Add godoc comments * Add missing err check * gofmt * Bump things to 1.18 * Update staticcheck, drop golint * Fix io/ioutil deprecation * Run gofmt * boilerplate
1 parent 4270e04 commit 6ba20c8

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

98 files changed

+445
-414
lines changed

.github/workflows/build.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ jobs:
1212

1313
strategy:
1414
matrix:
15-
go-version: [1.18] # TODO: add 1.19
15+
go-version: [1.18, 1.19] # TODO: add 1.20
1616

1717
steps:
1818
- uses: actions/checkout@v3

.github/workflows/release.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ jobs:
1515
run: git fetch --prune --unshallow
1616
- uses: actions/setup-go@v3
1717
with:
18-
go-version: 1.17
18+
go-version: 1.18
1919
check-latest: true
2020
- uses: goreleaser/[email protected]
2121
id: run-goreleaser

.github/workflows/test.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ jobs:
1111
test:
1212
strategy:
1313
matrix:
14-
go-version: [1.18] # TODO: add 1.19
14+
go-version: [1.18, 1.19] # TODO: add 1.20
1515

1616
name: Unit Tests
1717
runs-on: ubuntu-latest

cmd/crane/cmd/auth.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ import (
1818
"encoding/json"
1919
"errors"
2020
"fmt"
21-
"io/ioutil"
21+
"io"
2222
"log"
2323
"os"
2424
"strings"
@@ -86,7 +86,7 @@ func NewCmdAuthGet(options []crane.Option, argv ...string) *cobra.Command {
8686
if len(args) == 1 {
8787
registryAddr = args[0]
8888
} else {
89-
b, err := ioutil.ReadAll(os.Stdin)
89+
b, err := io.ReadAll(os.Stdin)
9090
if err != nil {
9191
return err
9292
}
@@ -170,7 +170,7 @@ type loginOptions struct {
170170

171171
func login(opts loginOptions) error {
172172
if opts.passwordStdin {
173-
contents, err := ioutil.ReadAll(os.Stdin)
173+
contents, err := io.ReadAll(os.Stdin)
174174
if err != nil {
175175
return err
176176
}

cmd/crane/cmd/export.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@ package cmd
1717
import (
1818
"fmt"
1919
"io"
20-
"io/ioutil"
2120
"log"
2221
"os"
2322

@@ -55,7 +54,7 @@ func NewCmdExport(options *[]crane.Option) *cobra.Command {
5554

5655
var img v1.Image
5756
if src == "-" {
58-
tmpfile, err := ioutil.TempFile("", "crane")
57+
tmpfile, err := os.CreateTemp("", "crane")
5958
if err != nil {
6059
log.Fatal(err)
6160
}

cmd/crane/cmd/push.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@ package cmd
1616

1717
import (
1818
"fmt"
19-
"io/ioutil"
2019
"os"
2120

2221
"github.com/google/go-containerregistry/pkg/crane"
@@ -72,7 +71,7 @@ func NewCmdPush(options *[]crane.Option) *cobra.Command {
7271

7372
digest := ref.Context().Digest(h.String())
7473
if imageRefs != "" {
75-
return ioutil.WriteFile(imageRefs, []byte(digest.String()), 0600)
74+
return os.WriteFile(imageRefs, []byte(digest.String()), 0600)
7675
}
7776
// TODO(mattmoor): think about printing the digest to standard out
7877
// to facilitate command composition similar to ko build.

cmd/crane/cmd/root.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
// Copyright 2019 Google LLC All Rights Reserved.
2+
//
13
// Licensed under the Apache License, Version 2.0 (the "License");
24
// you may not use this file except in compliance with the License.
35
// You may obtain a copy of the License at

cmd/crane/cmd/util.go

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,17 @@
1+
// Copyright 2020 Google LLC All Rights Reserved.
2+
//
3+
// Licensed under the Apache License, Version 2.0 (the "License");
4+
// you may not use this file except in compliance with the License.
5+
// You may obtain a copy of the License at
6+
//
7+
// http://www.apache.org/licenses/LICENSE-2.0
8+
//
9+
// Unless required by applicable law or agreed to in writing, software
10+
// distributed under the License is distributed on an "AS IS" BASIS,
11+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
// See the License for the specific language governing permissions and
13+
// limitations under the License.
14+
115
package cmd
216

317
import (

cmd/crane/cmd/version.go

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,17 @@
1+
// Copyright 2019 Google LLC All Rights Reserved.
2+
//
3+
// Licensed under the Apache License, Version 2.0 (the "License");
4+
// you may not use this file except in compliance with the License.
5+
// You may obtain a copy of the License at
6+
//
7+
// http://www.apache.org/licenses/LICENSE-2.0
8+
//
9+
// Unless required by applicable law or agreed to in writing, software
10+
// distributed under the License is distributed on an "AS IS" BASIS,
11+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
// See the License for the specific language governing permissions and
13+
// limitations under the License.
14+
115
package cmd
216

317
import (

cmd/crane/help/main.go

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,17 @@
1+
// Copyright 2018 Google LLC All Rights Reserved.
2+
//
3+
// Licensed under the Apache License, Version 2.0 (the "License");
4+
// you may not use this file except in compliance with the License.
5+
// You may obtain a copy of the License at
6+
//
7+
// http://www.apache.org/licenses/LICENSE-2.0
8+
//
9+
// Unless required by applicable law or agreed to in writing, software
10+
// distributed under the License is distributed on an "AS IS" BASIS,
11+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
// See the License for the specific language governing permissions and
13+
// limitations under the License.
14+
115
package main
216

317
import (

0 commit comments

Comments
 (0)