gopls returns the error "gopls: no packages returned: packages.Load error" for


I’ve checked out the main branch of (at commit 947343309601b4eb3c2fa3e7d15d701b503dd491 ) but I notice that in VS Code I can’t "Go to definition" as usual. If I hover over the package name sarama in functional_consumer_group_test.go, I get the linter warning

No packages found for open file /Users/kurtpeek/go/src/ <nil>.
If this file contains build tags, try adding "-tags=<build tag>" to your gopls "buildFlags" configuration (see (
Otherwise, see the troubleshooting guidelines for help investigating ( list

(See screenshot below).

enter image description here

From the command line, if I try to gopls that file, I get a similar error:

> gopls check functional_consumer_group_test.go 
gopls: no packages returned: packages.Load error

I suspect this has something to do with the build constraints ( in that file, from,

//go:build functional
// +build functional

It’s not clear to me, however, how to modify my VS Code settings.json to pass these build constraints. Does anyone know how to get this functional test to build?


Following, I had to create a .vscode/settings.json file in the repository’s root directory and add the following contents:

    "go.buildFlags": [
    "go.testTags": "functional",

Now VS Code works like normal in that file:

enter image description here

Answered By – Kurt Peek

Answer Checked By – Mary Flores (GoLangFix Volunteer)

Leave a Reply

Your email address will not be published.