So, you want to debug some Go in VS Code. And maybe setup some Docker containers with services before? How the hell do you configure that?
Imagine that you are working on a large Go project, with pkg, internal, cmd and all the folders, and want to debug while running against several local containers, like databases, or Kafka.
The documentation in the VS Code docs is a bit confusing, or excessively long. You need two files in your .vscode. The first is launch.json, if you don’t have one as soon as you trigger the debugger it will prompt you to create one.
You may not need all the settings, but I left them in case they are helpful.
The setup above is required for launching a debugger, and preLaunchTask is the label of a task defined in task.json, also in your .vscode folder. It will run before starting the debugger. And postDebugTask will run once you stop the debugger. Like a setup and teardown in a test suite.