Right click the function name.
Select item 'Go: Generate Unit Tests for Function' in the pop-up menu:

A test file named <file name>_test.go is generated for you:

If you got below error message, click the Install button to install gotests:

| ZhangZhihui's Blog |
|
||
![]() |
|
|
博客园
|
|