You can add following snippets to VSCode settings.json
to specify environment variables just for go test
runs:
"go.testEnvVars": {
"MY_VAR": "my value"
},
Or using dedicated file (in my example called .env
in root of project workspace) containing the environment variables in MY_VAR="my value"
format with one variable per line:
"go.testEnvFile": "${workspaceFolder}/.env",