需要安装的软件:
- golang 1.20
- vscode
- vscode推荐的go插件
在RUN按钮中,创建Launch
自动生成launch.json文件,此处增加了:args参数。
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"name": "Launch Package",
"type": "go",
"request": "launch",
"mode": "auto",
"program": "${fileDirname}",
"args": [
"--version"
]
}
]
}
注意:这里- -version,不是version。
接下来,给程序打断点,启动