Visual Studio Code Go test snippets

October 1, 2019
golang | testing | vscode

In my previous post, I’ve outlined how I write tests.

Since I ended up writing a lot of code multiple times, I made my life slightly easier by creating two simple snippets for Visual Studio Code.


You can use the tcimp snippet to quickly add the basic imports needed for writing a test.

It uses the testing and assert libaries.

Just type tcimp and you’ll get the following snippet:

import (



tcimp snippet


Typing tc sets up the basic structure for an empty test and results in:

func Test_<name>(t *testing.T) {

	type test struct {
		name string

	var tests = []test{}

	for _, tc := range tests {
		t.Run(, func(t *testing.T) {


tc snippet

You can get the snippets from here.