I’ve recently started writing services in Golang. Using the VSCode debugger has helped me learn (and save me a lot of time!). Lets quickly run through how to set it up.
Under the Run And Debug
tab in VSCode, click create a launch.json file
.
In this file is where we’ll add configuration for our Go program. This is an example configuration for a simple program called greetings
. The folder structure looks like this:
/greetings
go.mod
go.sum
greetings_test.go
greetings.go
.env.development
And the launch.json
:
And that’s it! To test it out, set a breakpoint and run your tests(s). Here’s the code for the module and its unit test.
greetings.go
greetings_test.go