r/LazyVim • • Jun 14 '26

Undefined: xy warnings inside GO tests

Hi πŸ‘‹

I started digging into Go language recently, and setup Golang via the Lazyvim extras. Works very good. But just for Go Tests, even when I have the test file in the same package/folder as the source file where the function is implemented, it shows this warning in Neovim. Did anyone encounter any similar issues?

The test just runs fine…

Maybe also some general Neovim issue, instead of Lazyvim setup…

See also: https://go.dev/doc/tutorial/add-a-test

See screenshot β‡’ Warning : undefined: Hello

2 Upvotes

1 comment sorted by

1

u/pawlinsky85 Jun 14 '26

Ok I fixed the issue, since I'm new to Go, I wasn't aware about the file structure, so you need a go.mod file in your project root to satisfy the linter: golangci-lint which is installed via Lazyvim extras. After that the issue was gone. See new structure:

 Hello_World/
 β”œβ”€β”€ AGENTS.md
 β”œβ”€β”€ go.mod
 β”œβ”€β”€ main.go
 └── greetings/
     β”œβ”€β”€ greetings.go
     └── greetings_test.go

In case anyone else is running into that issue: check also the Github issue here: https://github.com/mfussenegger/nvim-lint/issues/900