diff options
author | Patrick Steinhardt <psteinhardt@gitlab.com> | 2021-09-16 16:29:41 +0300 |
---|---|---|
committer | Patrick Steinhardt <psteinhardt@gitlab.com> | 2021-09-20 17:23:54 +0300 |
commit | bb18ad9cb4e00d69207f856263c65b46aea37046 (patch) | |
tree | 2e2998c2bc74f1df9ce05e962ecda4da74c13a3c | |
parent | 4d63c8f0bfb5874ba2a9a68be0b3d73d9669cd09 (diff) |
golangci: Disallow usage of "io/ioutil" package
The "io/ioutil" package has been deprecated in Go 1.16 and thus
shouldn't be used in our codebase anymore. Disallow its usage by adding
the "depguard" linter with a single entry for this specific package.
Note that we still use the package in some places where we used to rely
on `ioutil.ReadDir()`'s old behaviour of stat'ting all directory
entries. Conversion of these is not part of this patch series given that
it would be a change in behaviour compared to all the other changes
which aren't. Those sites are thus annotated with `nolint` directives.
-rw-r--r-- | .golangci.yml | 8 | ||||
-rw-r--r-- | internal/cache/keyer.go | 1 | ||||
-rw-r--r-- | internal/cache/walker.go | 1 | ||||
-rw-r--r-- | internal/git/stats/profile.go | 1 | ||||
-rw-r--r-- | internal/gitaly/service/repository/cleanup.go | 1 | ||||
-rw-r--r-- | internal/gitaly/service/repository/gc.go | 1 | ||||
-rw-r--r-- | internal/tempdir/clean.go | 1 |
7 files changed, 14 insertions, 0 deletions
diff --git a/.golangci.yml b/.golangci.yml index d98c295a5..4b7eeab90 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -11,6 +11,7 @@ linters: - deadcode - errcheck - exportloopref + - depguard - gci - gofumpt - goimports @@ -723,3 +724,10 @@ issues: max-issues-per-linter: 0 # Maximum count of issues with the same text. Set to 0 to disable. Default is 3. max-same-issues: 0 + +linters-settings: + depguard: + list-type: blacklist + include-go-root: true + packages-with-error-message: + - io/ioutil: "ioutil is deprecated starting with Go 1.16" diff --git a/internal/cache/keyer.go b/internal/cache/keyer.go index 1149103b3..31e810d14 100644 --- a/internal/cache/keyer.go +++ b/internal/cache/keyer.go @@ -1,5 +1,6 @@ package cache +//nolint:depguard import ( "context" "crypto/sha256" diff --git a/internal/cache/walker.go b/internal/cache/walker.go index a71a2819c..bfd5fba01 100644 --- a/internal/cache/walker.go +++ b/internal/cache/walker.go @@ -5,6 +5,7 @@ // worker will walk the cache directory every ten minutes. package cache +//nolint:depguard import ( "fmt" "io/ioutil" diff --git a/internal/git/stats/profile.go b/internal/git/stats/profile.go index 2bdc0e9f1..a9a2ced15 100644 --- a/internal/git/stats/profile.go +++ b/internal/git/stats/profile.go @@ -1,5 +1,6 @@ package stats +//nolint:depguard import ( "context" "errors" diff --git a/internal/gitaly/service/repository/cleanup.go b/internal/gitaly/service/repository/cleanup.go index 060dd7215..c1302053f 100644 --- a/internal/gitaly/service/repository/cleanup.go +++ b/internal/gitaly/service/repository/cleanup.go @@ -1,5 +1,6 @@ package repository +//nolint:depguard import ( "bytes" "context" diff --git a/internal/gitaly/service/repository/gc.go b/internal/gitaly/service/repository/gc.go index dda5f71a9..3dd03b143 100644 --- a/internal/gitaly/service/repository/gc.go +++ b/internal/gitaly/service/repository/gc.go @@ -1,5 +1,6 @@ package repository +//nolint:depguard import ( "context" "errors" diff --git a/internal/tempdir/clean.go b/internal/tempdir/clean.go index 0bef52c3e..327423225 100644 --- a/internal/tempdir/clean.go +++ b/internal/tempdir/clean.go @@ -1,5 +1,6 @@ package tempdir +//nolint:depguard import ( "context" "fmt" |