Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
5 tasks done
kikihakiem opened this issue Aug 9, 2023 · 3 comments
Closed
5 tasks done

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

kikihakiem opened this issue Aug 9, 2023 · 3 comments
Labels
question Further information is requested

Comments

@kikihakiem
Copy link

kikihakiem commented Aug 9, 2023

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.).
@kikihakiem kikihakiem added the bug Something isn't working label Aug 9, 2023
@boring-cyborg
Copy link

boring-cyborg bot commented Aug 9, 2023

Hey, thank you for opening your first Issue ! 🙂 If you would like to contribute we have a guide for contributors.

@ldez
Copy link
Member

ldez commented Aug 9, 2023

Hello,

I'm not able to reproduce the problem.

module github.com/golangci/example

go 1.21
package main

import (
	"log/slog"
)

func main() {
	slog.Info("Hello world!")
}
$ golangci-lint version 
golangci-lint has version 1.54.0 built with go1.21.0 from c1d8c565 on 2023-08-09T11:50:00Z
$ go version           
go version go1.21.0 linux/amd64
$ golangci-lint run
$

@ldez ldez added the feedback required Requires additional feedback label Aug 9, 2023
@kikihakiem
Copy link
Author

The problem was because the GOPATH pointed to the root folder of go1.20 even though I used go1.21 binary. The issue is fixed after I updated the GOPATH to go1.21. Thank you for your swift response @ldez !

@ldez ldez added question Further information is requested and removed bug Something isn't working feedback required Requires additional feedback labels Aug 9, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

2 participants