go-ruleguard: go1.21: load rules: parse rules file: typechecker error: ...: could not import
Hello,
I know it’s a bit early but I started to work on go1.21 for golangci-lint. https://github.com/golangci/golangci-lint/pull/3922
And there is an issue with go-ruleguard. I run the tests of go-ruleguard and there is the same problem:
ruleguard init error, skip ./rules.go: typechecker error: ./rules.go:6:8: could not import github.com/quasilyte/go-ruleguard/dsl (can't find import: "github.com/quasilyte/go-ruleguard/dsl")
Currently, I don’t know the root cause but I want to share it with you, I think will you see the problem faster than me.
Maybe it’s related to the new package initialization order, I don’t know.
I already created an issue on go-critic.
go test
$ go test ./...
? github.com/quasilyte/go-ruleguard [no test files]
? github.com/quasilyte/go-ruleguard/analyzer/testanalyzer [no test files]
? github.com/quasilyte/go-ruleguard/cmd/ruleguard [no test files]
? github.com/quasilyte/go-ruleguard/internal/golist [no test files]
? github.com/quasilyte/go-ruleguard/internal/xtypes [no test files]
? github.com/quasilyte/go-ruleguard/ruleguard/goutil [no test files]
? github.com/quasilyte/go-ruleguard/ruleguard/ir [no test files]
? github.com/quasilyte/go-ruleguard/ruleguard/irprint [no test files]
? github.com/quasilyte/go-ruleguard/ruleguard/profiling [no test files]
? github.com/quasilyte/go-ruleguard/ruleguard/quasigo/internal/evaltest [no test files]
? github.com/quasilyte/go-ruleguard/ruleguard/quasigo/stdlib/qfmt [no test files]
? github.com/quasilyte/go-ruleguard/ruleguard/quasigo/stdlib/qstrconv [no test files]
? github.com/quasilyte/go-ruleguard/ruleguard/quasigo/stdlib/qstrings [no test files]
--- FAIL: TestAnalyzer (4.78s)
--- FAIL: TestAnalyzer/gocritic (0.38s)
analysistest.go:295: error analyzing ruleguard@gocritic: load rules: parse rules file: typechecker error: ./testdata/src/gocritic/rules.go:6:8: could not import github.com/quasilyte/go-ruleguard/dsl (can't find import: "github.com/quasilyte/go-ruleguard/dsl")
...
About this issue
- Original URL
- State: closed
- Created a year ago
- Comments: 22 (21 by maintainers)
Commits related to this issue
- update to golangci-lint v1.54.0 + go-ruleguard v0.4.0 That release is the first one with official support for Go 1.21. go-ruleguard must be >= 0.3.20 because of https://github.com/quasilyte/go-rulegu... — committed to pohly/kubernetes by pohly a year ago
- update to golangci-lint v1.54.1 + go-ruleguard v0.4.0 That release is the first one with official support for Go 1.21. go-ruleguard must be >= 0.3.20 because of https://github.com/quasilyte/go-rulegu... — committed to pohly/kubernetes by pohly a year ago
- update to golangci-lint v1.54.1 + go-ruleguard v0.4.0 That release is the first one with official support for Go 1.21. go-ruleguard must be >= 0.3.20 because of https://github.com/quasilyte/go-rulegu... — committed to pohly/kubernetes by pohly a year ago
- update to golangci-lint v1.54.1 + go-ruleguard v0.4.0 That release is the first one with official support for Go 1.21. go-ruleguard must be >= 0.3.20 because of https://github.com/quasilyte/go-rulegu... — committed to pohly/kubernetes by pohly a year ago
- update to golangci-lint v1.54.1 + go-ruleguard v0.4.0 That release is the first one with official support for Go 1.21. go-ruleguard must be >= 0.3.20 because of https://github.com/quasilyte/go-rulegu... — committed to pohly/kubernetes by pohly a year ago
- update to golangci-lint v1.54.1 + go-ruleguard v0.4.0 That release is the first one with official support for Go 1.21. go-ruleguard must be >= 0.3.20 because of https://github.com/quasilyte/go-rulegu... — committed to pohly/kubernetes by pohly a year ago
Maybe someone can reopen this issue.
go env
output changed in go1.21 to be single-quoted and escape single quotes as'\''
in https://go-review.googlesource.com/c/go/+/493535parseGoEnv() in https://github.com/quasilyte/go-ruleguard/blob/master/internal/goenv/goenv.go has to handle both double-quoted and single-quoted formats now, something like:
The rc4 is here, the GA is closer than ever.
@quasilyte can I help you?
see my PR #451
hrmm… my fix resolved the issue I was seeing finding stdlib imports… the error you’re seeing looks to be in resolving non-stdlib imports
there may be more issues to resolve here, though
I try your suggestion (I will remove it after) inside my PR https://github.com/quasilyte/go-ruleguard/pull/451 And it works!