(WSL2 VSCode) Go CodeLens not showing run test | debug test

63 views Asked by At

I've been trying to learn Golang backend development and have been following this Youtube guide

https://www.youtube.com/playlist?list=PLy_6D98if3ULEtXtNSY_2qN21VCKgoQAE

But when learning about writing tests i've found that my vscode doesn't display the 'run tests | debug tests' Codelens. I'm running my vscode from my WSL2 Ubuntu using the 'code .' command.

code and proj structure

I was also wondering if the command go test ./db/sqlc/ -run TestCreateAccoun offers that same functionality as this codelens?

The steps that i've tried already have been to

  • disable and re-enable the 'Editor: Code Lens' setting in preferences
  • restart my WSL
  • reinstall go extension
  • Double check documentation, I follow the file naming convention ending in _test.go and my function starts with Test docs
  • followed debugging steps described by others in this post but nothing worked

I was wondering if anyone knew further debug steps - i'm willing to give necessary output.

1

There are 1 answers

1
Peter Verschuure On

To answer your second question, go test ./db/sqlc/ -run TestCreateAccount is indeed equivalent to the run test button in VS Code. The debug test button starts the debugger.

Regarding your initial question, are the Go > Test Explorer: Enable and Go > Tasks: Provide Default checkmarks set? You can find these through Settings > Settings > User Settings > search for "go test enable" as shown in attached image. enter image description here