当前位置: 首页 > 工具软件 > godebug > 使用案例 >

vscode golang debug 配置

李和昶
2023-12-01

1、F5点击配置Launch.json,  把program那个变量的值改一下,改成 "program": "${workspaceFolder}", 意思是调试的时候,以当前打开的文件夹根目录作为工程目录进行调试。


{
    // 使用 IntelliSense 了解相关属性。 
    // 悬停以查看现有属性的描述。
    // 欲了解更多信息,请访问: https://go.microsoft.com/fwlink/?linkid=830387
    "version": "0.2.0",
    "configurations": [
        {
            "name": "Launch",
            "type": "go",
            "request": "launch",
            "mode": "auto",
            "program": "${workspaceFolder}",
            "env": {},
            "args": []
        }
    ]
}
 

2、若报错提示 

Build Error: go build -o c:\Users\yangqing\Documents\Gitee\go_dev\src__debug_bin.exe -gcflags all=-N -l .
go: go.mod file not found in current directory or any parent directory; see 'go help modules' (exit status 1)

在cmd处, go env -w GO111MODULE=auto

 类似资料: