Skip to content

Commit

Permalink
Enable depguard on io/ioutil (#3695)
Browse files Browse the repository at this point in the history
Signed-off-by: Matthieu MOREL <mmorel-35@users.noreply.github.com>
  • Loading branch information
mmorel-35 committed May 23, 2022
1 parent f2c6bda commit f9992f7
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 5 deletions.
8 changes: 8 additions & 0 deletions .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,13 @@ run:
- cmd/ingester/app/consumer/mocks

linters-settings:
depguard:
list-type: blacklist
include-go-root: true
packages:
- io/ioutil
packages-with-error-message:
- io/ioutil: "Use os or io instead of io/ioutil"
goimports:
local-prefixes: github.com/jaegertracing/jaeger
gosec:
Expand All @@ -22,6 +29,7 @@ linters-settings:

linters:
enable:
- depguard
- gofmt
- goimports
- gosec
Expand Down
12 changes: 7 additions & 5 deletions pkg/gzipfs/gzip_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ package gzipfs

import (
"embed"
"io"
"io/fs"
"io/ioutil"
"testing"
"time"

Expand All @@ -38,9 +38,11 @@ type mockFile struct {
func (f *mockFile) Stat() (fs.FileInfo, error) {
return nil, f.err
}

func (f *mockFile) Read([]byte) (int, error) {
return 0, f.err
}

func (f *mockFile) Close() error {
return f.err
}
Expand All @@ -59,7 +61,7 @@ func TestFS(t *testing.T) {
{
name: "uncompressed file",
path: "testdata/foobar",
expectedMode: 0444,
expectedMode: 0o444,
expectedName: "foobar",
expectedSize: 11,
expectedContent: "hello world",
Expand All @@ -68,7 +70,7 @@ func TestFS(t *testing.T) {
{
name: "compressed file",
path: "testdata/foobar.gz",
expectedMode: 0444,
expectedMode: 0o444,
expectedName: "foobar.gz",
expectedSize: 38,
expectedContent: "", // actual gzipped payload is returned
Expand All @@ -77,7 +79,7 @@ func TestFS(t *testing.T) {
{
name: "compressed file accessed without gz extension",
path: "testdata/foobaz",
expectedMode: 0444,
expectedMode: 0o444,
expectedName: "foobaz",
expectedSize: 11,
expectedContent: "hello world",
Expand Down Expand Up @@ -126,7 +128,7 @@ func TestFS(t *testing.T) {
assert.Equal(t, c.expectedModTime, stat.ModTime())
assert.False(t, stat.IsDir())
assert.Nil(t, stat.Sys())
content, err := ioutil.ReadAll(f)
content, err := io.ReadAll(f)
require.NoError(t, err)
if c.expectedContent != "" {
assert.Equal(t, c.expectedContent, string(content))
Expand Down

0 comments on commit f9992f7

Please sign in to comment.