Create a devcontainer.json file in your project root to define the Go development environment with Docker.
{
"name": "Go",
"image": "mcr.microsoft.com/devcontainers/go:1",
"features": {
"ghcr.io/devcontainers/features/docker-in-docker:2": {}
},
"customizations": {
"vscode": {
"extensions": ["golang.go"]
}
}
}
- Create a
.devcontainerfolder in your project root and add thedevcontainer.jsonfile with the content above. - Open the project folder in VS Code and select "Reopen in Container" from the command palette.
- Run
go versionin the integrated terminal to verify the environment is active.