Skip to content

Issue with go1.21 and log/slog package #3996

@kikihakiem

Description

@kikihakiem

Welcome

Description of the problem

I'm facing an issue after upgrading to go1.21. Got an error saying:

ERRO Running error: 1 error occurred:
        * can't run linter goanalysis_metalinter: buildir: failed to load package : could not load export data: no export data for "log/slog"

It was running fine with go1.19 and go1.20. I tried both the binary release (v1.53.3) and build from the source using the master branch.

Related to #3933

Version of golangci-lint

$ golangci-lint --version
golangci-lint has version v1.53.4-0.20230809100920-e0a8bd8543bf built with go1.21.0 from (unknown, mod sum: "h1:JQgLCAw95Hm7lfdGahQupddWChuJt5yO4tCUydXEcmQ=") on (unknown)

Configuration

# paste configuration file or CLI flags here

Go environment

$ go version && go env
go version go1.21.0 darwin/arm64
GO111MODULE=''
GOARCH='arm64'
GOBIN=''
GOCACHE='/Users/backendengineer/Library/Caches/go-build'
GOENV='/Users/backendengineer/Library/Application Support/go/env'
GOEXE=''
GOEXPERIMENT=''
GOFLAGS=''
GOHOSTARCH='arm64'
GOHOSTOS='darwin'
GOINSECURE=''
GOMODCACHE='/opt/homebrew/Cellar/go/1.19.1/pkg/mod'
GONOPROXY=''
GONOSUMDB=''
GOOS='darwin'
GOPATH='/opt/homebrew/Cellar/go/1.19.1'
GOPRIVATE=''
GOPROXY='https://proxy.golang.org,direct'
GOROOT='/Users/backendengineer/sdk/go1.21.0'
GOSUMDB='sum.golang.org'
GOTMPDIR=''
GOTOOLCHAIN='auto'
GOTOOLDIR='/Users/backendengineer/sdk/go1.21.0/pkg/tool/darwin_arm64'
GOVCS=''
GOVERSION='go1.21.0'
GCCGO='gccgo'
AR='ar'
CC='clang'
CXX='clang++'
CGO_ENABLED='1'
GOMOD='/Users/backendengineer/workspace/bob/user_management/go.mod'
GOWORK=''
CGO_CFLAGS='-O2 -g'
CGO_CPPFLAGS=''
CGO_CXXFLAGS='-O2 -g'
CGO_FFLAGS='-O2 -g'
CGO_LDFLAGS='-O2 -g'
PKG_CONFIG='pkg-config'
GOGCCFLAGS='-fPIC -arch arm64 -pthread -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -ffile-prefix-map=/var/folders/c1/cnl2m3nj0sq9_1mbcn1h262w0000gp/T/go-build4256842410=/tmp/go-build -gno-record-gcc-switches -fno-common'

Verbose output of running

$ golangci-lint cache clean
$ golangci-lint run -v
INFO [config_reader] Config search paths: [redacted] 
INFO [lintersdb] Active 6 linters: [errcheck gosimple govet ineffassign staticcheck unused] 
INFO [loader] Go packages loading at mode 575 (files|name|imports|types_sizes|compiled_files|deps|exports_file) took 329.15925ms 
INFO [runner/filename_unadjuster] Pre-built 0 adjustments in 637.083µs 
INFO [linters_context/goanalysis] analyzers took 2.237174ms with top 10 stages: directives: 174.333µs, isgenerated: 166.25µs, cgocall: 160µs, tokenfileanalyzer: 155.958µs, typecheck: 150.541µs, errcheck: 147.666µs, SA4017: 123.334µs, framepointer: 119.667µs, SA4023: 91.959µs, S1011: 76.75µs 
WARN [runner] Can't run linter goanalysis_metalinter: buildir: failed to load package : could not load export data: no export data for "log/slog" 
INFO [runner] processing took 1.665µs with stages: max_same_issues: 291ns, skip_dirs: 250ns, filename_unadjuster: 167ns, severity-rules: 166ns, sort_results: 125ns, nolint: 125ns, max_per_file_from_linter: 84ns, diff: 83ns, max_from_linter: 83ns, exclude: 42ns, identifier_marker: 42ns, cgo: 42ns, skip_files: 42ns, uniq_by_line: 41ns, exclude-rules: 41ns, fixer: 41ns, source_code: 0s, autogenerated_exclude: 0s, path_prefixer: 0s, path_shortener: 0s, path_prettifier: 0s 
INFO [runner] linters took 10.330208ms with stages: goanalysis_metalinter: 10.305792ms 
ERRO Running error: 1 error occurred:
        * can't run linter goanalysis_metalinter: buildir: failed to load package : could not load export data: no export data for "log/slog"
 
INFO Memory: 5 samples, avg is 24.0MB, max is 27.2MB 
INFO Execution took 346.8315ms 

Code example or link to a public repository

package main

import (
	"log/slog"
)

func main() {
	slog.Info("Hello world!")
}

Validation

  • Yes, I've included all information above (version, config, etc.).

Metadata

Metadata

Assignees

No one assigned

    Labels

    questionFurther information is requested

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions