bazel-contrib / bazel-contrib/rules_go
Empty go.mod file in /tests: "missing module declaration"
- Dominant language
- Go
- Stars
- 1.5k
- Forks
- 760
- Avg merge
- 1d 11h
- Merged PRs (30d)
- 12
Description
### What version of rules_go are you using?
0.44.2
### What version of gazelle are you using?
0.35.0
### What version of Bazel are you using?
7.0.0
### Does this issue reproduce with the latest releases of all the above?
I cleaned my project and changed MODULE.bazel to use rules_go v0.46.0.
The error seems to be resolved. When I looked at the go.mod file for 0.46.0, it hasn't changed,
but there is a commit that seems to have corrected things. You might want to verify my
conclusion. Here is the commit: https://github.com/bazelbuild/rules_go/pull/3775
### What operating system and processor architecture are you using?
macOS Sonoma, v 14.2.1
amd64
### Any other potentially useful information about your toolchain?
go version go1.21.6 darwin/amd64
Goland Info:
GoLand 2023.3.4
Build #GO-233.14475.38, built on February 13, 2024
Runtime version: 17.0.10+1-b1087.17 x86_64
VM: OpenJDK 64-Bit Server VM by JetBrains s.r.o.
macOS 14.2.1
GC: G1 Young Generation, G1 Old Generation
Memory: 4096M
Cores: 24
Metal Rendering is ON
Registry:
debugger.new.tool.window.layout=true
ide.completion.variant.limit=500
suggest.all.run.configurations.from.context=true
ide.experimental.ui=true
Non-Bundled Plugins:
lechuck.intellij-plugin.task (1.5.0)
com.planetexpress.go_struct_tag_generator (1.2.8)
String Manipulation (9.12.0)
org.intellij.plugins.hcl (233.13135.65)
org.toml.lang (233.13135.67)
com.jetbrains.space (233.14475.8)
com.intellij.kubernetes (233.14475.2)
GOROOT=/usr/local/opt/go/libexec #gosetup
GOPATH=/Users/mike/Go #gosetup
### What did you do?
When I open my golang project in JetBrains GoLand, something runs the following command:
/usr/local/opt/go/libexec/bin/go list -modfile=/Users/mike/Go/src/github.com/ingios/falcon/bazel-falcon/external/rules_go~0.44.2/tests/go.mod -m -json -mod=mod all #gosetup
When I look at the go.mod file in that directory, it is empty and does not have a module statement.
Here is the error in the window that ran that command:
go: error reading /Users/mike/Go/src/github.com/ingios/falcon/bazel-falcon/external/rules_go~0.44.2/tests/go.mod: missing module declaration. To specify the module path:
go mod edit -module=example.com/mod
### What did you expect to see?
No error
### What did you see instead?
The reported error
Contributor guide
Research direction
Inspect the empty tests/go.mod in rules_go 0.44.2 and compare it with the version in 0.46.0. Review pull request 3775, then reproduce the GoLand command using the reported project setup. The issue is resolved when the command no longer reports a missing module declaration.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- go
- Domain
- build-system
- Issue type
- Bug
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100