profile
viewpoint

Ask questionsgolangci-lint "DecodeRune not declared by package utf8" with golang 1.13

Please include the following information:

  1. Version of golangci-lint: 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
  1. Config file: cat .golangci.yml - none

  2. 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"
  1. Verbose output of running: 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
golangci/golangci-lint

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
useful!

Related questions

confusing error message "File is not goimports-ed (goimports)" hot 203
Build errors using Go 1.13 hot 49
BUG: failed run hot 47
Setting GO111MODULE=on for golangci.com hot 31
ERRO Running error: context loading failed: failed to load program with go/packages hot 27
go get cmd/golangci-lint fails on Go 1.13 (tip) which uses proxy.golang.org (HTTP error 410 Gone) hot 22
Golangci-lint Incompatibility with newer versions of Go? hot 19
please surpport ignore someOne fuction's igored error hot 15
Cannot `go get` due to invalid pseudo-version hot 15
govet. WARN [runner] Can't process result by autogenerated_exclude processor: can't filter issue hot 14
VS Code can't find .golangci.yml hot 14
go get cmd/golangci-lint fails on Go 1.13 (tip) which uses proxy.golang.org (HTTP error 410 Gone) hot 13
Travis-CI: Context loading failed: could not determine GOARCH and Go compiler hot 13
panic on bodyclose hot 12
concurrent map access on 1.17.1 hot 12
Github User Rank List