DEV Community

vuong ⛈️
vuong ⛈️

Posted on

Go in VSCode: Must-have extensions and some limitations

If you want to be the best on VSCode instead use Goland, you can try!

But, please keep in your mind that you're trying to use VSCode, an open-source software, it might be unstable/not really optimal/not really minimalistic in some cases, and you get it free and you can contribute for helping a lot of developers in the world do the development process better.

Dependencies

Firstly, you should ensure that you already installed all dependencies of Go to help VScode can get thing done. Read it please https://github.com/Microsoft/vscode-go/wiki/Go-tools-that-the-Go-extension-depends-on

Go

Rich Go language supports for Visual Studio Code
https://marketplace.visualstudio.com/items?itemName=ms-vscode.Go

  • After installed, VSCode will notify all needed dependencies, then just click on Install button.

  • If the notification was not shown, please take a look on this one and install it manually https://github.com/Microsoft/vscode-go/wiki/Go-tools-that-the-Go-extension-depends-on

  • Note: gometalinter will be deprecated in future, so it should be an optional. The alternative is golangci-lint, take a look in their github to see how to setting up it.

  • Otherwise, let's go to extension description, it explained well about many things you're needing for make your deveploment process works smoothly.

Go Outliner

Go Outliner

Outline explorer for showing struct, methods in struct, types, functions, constants, testcases, benchmarks...
https://marketplace.visualstudio.com/items?itemName=766b.go-outliner

  • Although, VSCode explorer has its own outliner, it has the limitation that you couldn't get full of list struct methods when you seeing in a specific file of Go package.

  • I wish I can disable temporarily Testing explorer of Go Outliner! You can see the reason in the next extension! And I assume that I could remove Go Outliner when this issue is closed https://github.com/microsoft/vscode-go/issues/2370

Go Test Explorer

Go Test Explorer

Testcases explorer for project. It helps to run single test, file tests, all tests
https://marketplace.visualstudio.com/items?itemName=premparihar.gotestexplorer

  • But, wait, I've installed Go Outliner and isn't it enough? > Yes! Go Outliner is actually doing testing unwell. The execution of testing feature in Go Outliner provided wrong command, then it can't found my tests.
// Go Outliner
go test -run ^(TestRouteGroup)$
> ?       github.com/myproject     [no test files]
Enter fullscreen mode Exit fullscreen mode

Meanwhile, Go Test Explorer providing the right path, so the test can be completed with the result. That's all.

// Go Test Explorer
/Users/MY_USERNAME/.gvm/gos/go1.12.5/bin/go test -timeout 30s github.com/myproject/controllers/event -run ^(TestRouteGroup)$ -count=1 -coverprofile=/var/folders/b9/fc04ql552lg3wf_rtsdnqvnc0000gq/T/vscode-goMGfN9Z/go-code-cover

FAIL    github.com/myproject/controllers/event [build failed]
Error: Tests failed.
Enter fullscreen mode Exit fullscreen mode

If Go Outliner fixed this error, then I would say that Go Test Explorer might be removed on my VSCode for simplicity.

Latest comments (1)

Collapse
 
devfor profile image
Devfor acgency

Devfor'll help you grow awareness, connect with your target customers and generate more sales for your business with proven marketing tactics!
devfor.co
how a web development agency can help your business reach new heights in 2023