You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Our project uses bazel with a monorepo setup, I am using vscode and trying to get gopls working with my golang projects. The OS I am running is ubuntu 24.04.
package main
import "fmt"
func main() {
fmt.Println("this is an agent in go")
}
What did you see happen?
So compling is fine with the project, the external packages (including the pb.go packages generated from .proto files with bazel) is working well, I can use F12 to go to the definitions, use autofills etc. However, the standard libraries are broken, e.g. fmt, http.
The source code of "fmt" package is there under ***/go_sdk/src directory.
When I hover the mouse on "fmt", it shows error:
could not import fmt (missing metadata for import of "fmt")compilerBrokenImport
If I press F12, it says:
No definition found for "fmt"
What did you expect to see?
When I hover on "fmt" and press F12, vscode should take me to the source code of "fmt".
The text was updated successfully, but these errors were encountered:
opheadacheh
added
gopls
Issues related to the Go language server, gopls.
Tools
This label describes issues relating to any tools in the x/tools repository.
labels
Dec 19, 2024
The error doesn't look exactly same and the solution doesn't really work for me, but I agree this looks more like a bazel issue, I will file an issue there.
gopls version
(version: v0.17.0 built with go: go1.23.4)
go env
What did you do?
Our project uses bazel with a monorepo setup, I am using vscode and trying to get gopls working with my golang projects. The OS I am running is ubuntu 24.04.
My vscode settings looks like this:
Here is my sample golang code:
What did you see happen?
So compling is fine with the project, the external packages (including the pb.go packages generated from .proto files with bazel) is working well, I can use F12 to go to the definitions, use autofills etc. However, the standard libraries are broken, e.g. fmt, http.
The source code of "fmt" package is there under ***/go_sdk/src directory.
When I hover the mouse on "fmt", it shows error:
could not import fmt (missing metadata for import of "fmt")compilerBrokenImport
If I press F12, it says:
No definition found for "fmt"
What did you expect to see?
When I hover on "fmt" and press F12, vscode should take me to the source code of "fmt".
When I call fmt.***, autofill should work.
Editor and settings
No response
Logs
[Trace - 20:44:31.202 PM] Sending request 'textDocument/hover - (118)'.
Params: {"textDocument":{"uri":"file:///home/wanjia-he/Documents/robotics/data_pipeline/upload_agent_go/main.go"},"position":{"line":2,"character":11}}
[Error - Received] 20:44:31.202 PM #118 no package data for import "fmt"
[Error - 12:44:31 PM] Request textDocument/hover failed.
Message: no package data for import "fmt"
Code: 0
[Trace - 20:44:31.385 PM] Sending request 'textDocument/hover - (119)'.
Params: {"textDocument":{"uri":"file:///home/wanjia-he/Documents/robotics/data_pipeline/upload_agent_go/main.go"},"position":{"line":2,"character":10}}
[Error - Received] 20:44:31.385 PM #119 no package data for import "fmt"
[Error - 12:44:31 PM] Request textDocument/hover failed.
Message: no package data for import "fmt"
Code: 0
[Trace - 20:44:31.543 PM] Sending request 'textDocument/codeAction - (120)'.
Params: {"textDocument":{"uri":"file:///home/wanjia-he/Documents/robotics/data_pipeline/upload_agent_go/main.go"},"range":{"start":{"line":2,"character":7},"end":{"line":2,"character":12}},"context":{"diagnostics":[{"range":{"start":{"line":2,"character":7},"end":{"line":2,"character":12}},"message":"could not import fmt (missing metadata for import of "fmt")","code":"BrokenImport","codeDescription":{"href":"https://pkg.go.dev/golang.org/x/tools/internal/typesinternal#BrokenImport"},"severity":1,"source":"compiler"}],"only":["quickfix"],"triggerKind":1}}
[Trace - 20:44:31.544 PM] Received response 'textDocument/codeAction - (120)' in 0ms.
Result: null
[Trace - 20:44:31.544 PM] Received notification 'window/logMessage'.
Params: {"type":3,"message":"2024/12/19 20:44:31 fixImports(filename="/home/wanjia-he/Documents/robotics/data_pipeline/upload_agent_go/main.go"), srcDir="/home/wanjia-he/Documents/robotics/data_pipeline/upload_agent_go/main.go" ...%!(EXTRA string=/home/wanjia-he/Documents/robotics/data_pipeline/upload_agent_go)\n"}
[Info - 12:44:31 PM] 2024/12/19 20:44:31 fixImports(filename="/home/wanjia-he/Documents/robotics/data_pipeline/upload_agent_go/main.go"), srcDir="/home/wanjia-he/Documents/robotics/data_pipeline/upload_agent_go/main.go" ...%!(EXTRA string=/home/wanjia-he/Documents/robotics/data_pipeline/upload_agent_go)
The text was updated successfully, but these errors were encountered: