Golang meets VSCode

Golang meets VSCode

Every developement environment and its plugins have their pitfalls. The Go plugin offers many beneficial functionalities in VSCode. The necessaries are in place: code navigation, linting, autocompletion… Still, a developer fastly recognizes that the developing process takes place hardly. In this article we have a look at Writing Tests and Renaming and how to improve it.

Problems and solutions

Writing Tests

Testing is quite easy. All test files have to end with _test.go and all test functions have *testing.T as parameter. But if one tests much, one has to write many tests. This can be eased with gotests. Just put the executable into GOPATH to install. It is possible to generate tests and test files by interacting with a function, package or file to test. It implements a template for the functions’ input parameters. So the only thing to do is to create input parameters and which return is expected to implement complete tests.


Ranaming works as expected: Renaming functions or variables changes all references too. But there is one issue renaming. The more possibilieties to reference to are in GOPATH, the longer renaming takes. This is because the whole GOPATH is searched. To narrow the scope and lower renaming’s duration there is gorename. For installation just put the executable into GOPATH (just like Writing Tests) or simply run go get. Renaming just takes a few seconds now.


This are two problems, i struggled with, until i found these tools. I hope this helps you in production. These will not be the only or the last problems, which occure while developing. Neither this will not be my last article about this topic.

comments powered by Disqus