Ask questionsgolangci-lint "DecodeRune not declared by package utf8" with golang 1.13
Please include the following information:
golangci-lint --version (or git commit if you don't use binary distribution)$ golangci-lint --version
golangci-lint has version 1.17.1 built from 4ba2155 on 2019-06-10T09:07:35Z
Config file: cat .golangci.yml - none
Go environment: go version && go env
$ go version
go version go1.13 darwin/amd64
$ go env
GO111MODULE=""
GOARCH="amd64"
GOBIN=""
GOCACHE="/Users/foo/Library/Caches/go-build"
GOENV="/Users/foo/Library/Application Support/go/env"
GOEXE=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="darwin"
GONOPROXY=""
GONOSUMDB=""
GOOS="darwin"
GOPATH="/Users/foo/go"
GOPRIVATE=""
GOPROXY="https://proxy.golang.org,direct"
GOROOT="/usr/local/go"
GOSUMDB="sum.golang.org"
GOTMPDIR=""
GOTOOLDIR="/usr/local/go/pkg/tool/darwin_amd64"
GCCGO="gccgo"
AR="ar"
CC="clang"
CXX="clang++"
CGO_ENABLED="1"
GOMOD="/Users/foo/go/src/github.com/gardener/gardener-extensions/go.mod"
CGO_CFLAGS="-g -O2"
CGO_CPPFLAGS=""
CGO_CXXFLAGS="-g -O2"
CGO_FFLAGS="-g -O2"
CGO_LDFLAGS="-g -O2"
PKG_CONFIG="pkg-config"
GOGCCFLAGS="-fPIC -m64 -pthread -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -fdebug-prefix-map=/var/folders/p9/6dr9snnx6ws1dxkj4b66st6r0000gn/T/go-build176963248=/tmp/go-build -gno-record-gcc-switches -fno-common"
golangci-lint run -v$ golangci-lint run ./...
foo.go:1: /usr/local/go/src/regexp/regexp.go:967:22: DecodeRuneInString not declared by package utf8 (typecheck)
bar.go:1: /usr/local/go/src/mime/encodedword.go:130:22: DecodeRuneInString not declared by package utf8 (typecheck)
baz.go:1: /usr/local/go/src/go/token/token.go:317:16: DecodeRuneInString not declared by package utf8
Answer
questions
twpayne
Thanks, to explain what seems to be going on here:
golangci-lint, built with Go 1.12, will generate this error when linting Go 1.13 code.
If you're using a pre-built binary of golangci-lint then you'll run in to this error.
As @stevenh said, rebuilding golangci-lint fixes the error. Specifically, if you're currently following the golangci-lint install instructions (which downloads a pre-built binary from GitHub) then this will not work with Go 1.13. You'll have to install golangci-lint from source instead (at least until golangci-lint releases a version built with Go 1.13).
If you're installing golangci-lint with:
curl -sfL https://install.goreleaser.com/github.com/golangci/golangci-lint.sh | sh
Use this instead:
GO111MODULE=off go get -u github.com/golangci/golangci-lint/cmd/golangci-lint
Related questions