DEV Community

Melvin S
Melvin S

Posted on

[Shortcut] Run function test in Golang and VsCode

Simple Go Test File

No intro.

I'm tired of always clicking the Run Test above the function test. So I thought, there must be a shortcut to this. lol

Steps I took:

  1. Ctrl + Shift + P
  2. Keyboard Shortcuts
  3. Search "test"
  4. Double click on go.test.cursor
  5. Set your own keyboard shortcut. I went with Option + t
  6. Place the cursor anywhere inside the test function and run the test shortcut
  7. Voila!

Bonus

You can also set a shortcut on go.test.file to run all the tests in the opened file. I set mine to Option + Shift + T

Top comments (1)

Collapse
 
danish45007 profile image
Danish Sharma

thanks man it really saved a lot of time in testing unit functions separately