How to config debug the go project in vscode

To debug the go project has many method to achieve it

The config file specific the program arguments

 1{
 2    // Use IntelliSense to learn about possible attributes.
 3    // Hover to view descriptions of existing attributes.
 4    // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
 5    "version": "0.2.0",
 6    "configurations": [
 7        {
 8            "name": "cmd-name",
 9            "type": "go",
10            "request": "launch",
11            "mode": "auto",
12            "program": "src/cmd/main.go",            
13            "args": ["aws", "ecr", "create-repository", "--repository-name",  "test/repository"]
14        }
15    ]
16}

Set the environment variables

 1{
 2    // Use IntelliSense to learn about possible attributes.
 3    // Hover to view descriptions of existing attributes.
 4    // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
 5    "version": "0.2.0",
 6    "configurations": [
 7        {
 8            "name": "test-cmd",
 9            "type": "go",
10            "request": "launch",
11            "mode": "auto",
12            "env": {
13                "ENVIRONMENT": "dev"
14            },
15            "program": "${workspaceFolder}",
16            "dlvFlags": ["--check-go-version=false"]
17        }
18    ]
19}