2
答: 基於putus答案,我想通了,下面的配置來構建和調試與點擊調試圍棋在Visual Studio代碼,並深入調試器標籤
首先你需要一個任務添加到用各自的標籤構建二進制文件。
{
// See https://go.microsoft.com/fwlink/?LinkId=733558
// for the documentation about the tasks.json format
"version": "0.1.0",
"command": "bash",
"isShellCommand": true,
"args": [""],
"showOutput": "always",
"tasks": [
{
"taskName": "buildBinWithTag",
"command": "go",
"args": ["build", "-o", "BinaryName", "-tags", "THISISATAG"],
"isShellCommand": true
}
]
}
該任務應在調試器啓動之前執行。
{
"version": "0.2.0",
"configurations": [
{
"name": "DebugBinWithTag", //added config
"type": "go",
"request": "launch",
"mode": "exec",
"remotePath": "",
"port": 2345,
"host": "127.0.0.1",
"program": "${workspaceRoot}/BinaryName",
"env": {},
"args": [],
"showLog": true,
"preLaunchTask": "buildBinWithTag"
}
]
}
原題:我使用的是建立標籤用於編譯不同版本的圍棋程序和我編譯它「去建立標籤都有效THISISAFLAG」
//+build THISISAFLAG
package main
這完美的作品。但是有沒有辦法告訴調試器使用這些標誌。我嘗試使用類似以下的啓動配置,但它不起作用。
{
"version": "0.2.0",
"configurations": [
{
"name": "Launch",
"type": "go",
"request": "launch",
"mode": "debug",
"remotePath": "",
"port": 2345,
"host": "127.0.0.1",
"program": "${fileDirname}",
"env": {},
"args": ["-flags THISISAFLAG"],
"showLog": true
}
]
}
非常感謝!適用於調試! – David