vscode 调试几个方便的参数

主要是记录几个方便调试的变量,很多时候我们开发cli 应用,调试的时候就需要指定启动参数

调试配置文件

vscode提供了launch.json 的运行&&调试配置文件

几个常用变量

  • ${workspaceFolder} vscode 打开的文件夹路径
  • ${worrkspaceFolderBasename} 在vscode 中打开的不包含/的文件夹名称
  • ${file} 当前打开的文件
  • ${relativeFile} 相对workspaceFolder 的文件
    说明:其他变量可以参考以下链接资料

一个参考运行配置

 
{
    "version": "0.2.0",
    "configurations": [
        {
            "name": "Launch",
            "type": "go",
            "request": "launch",
            "mode": "auto",
            "program": "${workspaceFolder}/main.go",
            "env": {},
            "args": ["start"]
        }
    ]
}

参考资料

https://code.visualstudio.com/docs/editor/debugging#_launch-configurations
https://code.visualstudio.com/docs/editor/variables-reference

原文地址:https://www.cnblogs.com/rongfengliang/p/14087109.html