Alongkorn
Alongkorn

Reputation: 4217

how to use vscode to debug go 1.11.x

I am new to golang, but working on go 1.11.x.

My team use go module. The first time I clone the repository, I need to run GO111MODULE=on go mod download to download dependencies modules.

Then I need to run GO111MODULE=on go run main.go to run my app.

There is no one use vscode debugger, they prefer console log instead.

Is there any way to debug go 1.11.x using vscode?

Thanks.

Upvotes: 0

Views: 1400

Answers (1)

Alongkorn
Alongkorn

Reputation: 4217

I found the root cause right now. It is the source code of my team, not related to vscode or go 1.11.

My working launch.json is here

{
    "version": "0.2.0",
    "configurations": [

        {
            "name": "Go debug",
            "type": "go",
            "request": "launch",
            "mode": "debug",
            "remotePath": "",
            "port": 2345,
            "host": "127.0.0.1",
            "program": "${workspaceRoot}/main.go",
            "env": {
            //   "GO111MODULE": "on"
            },
            "args": [],
            "showLog": true
        }
    ]
}

Upvotes: 1

Related Questions