• vscode配置golang环境:settings.json和launch.json


    在项目根目录下面新建settings.json和launch.json文件:
     
    # settings.json 文件内容如下:主要是goroot和gopath
    {
        "files.autoSave": "onFocusChange",
        "go.buildOnSave": true,
        "go.lintOnSave": true,
        "go.vetOnSave": true,
        "go.buildTags": "",
        "go.buildFlags": [],
        "go.lintFlags": [],
        "go.vetFlags": [],
        "go.coverOnSave": false,
        "go.useCodeSnippetsOnFunctionSuggest": false,
        "go.formatOnSave": true,
        "go.formatTool": "goreturns",
        "go.goroot": "D:\App\Golang",    
        "go.gopath": "D:\Go", 
        "go.gocodeAutoBuild": true
    }
    # launch.json文件内容如下:主要是host和port
    {
        "version": "0.2.0",
        "configurations": [
            {
                "name": "igoodful",
                "type": "go",
                "request": "launch",
                "mode": "debug",
                "remotePath": "",
                "port": 2345,
                "host": "127.0.0.1",
                "program": "${workspaceRoot}\helloworld",
                "env": {},
                "args": []
            }
        ]
    }
    设置 launch.json 配置文件
    ctrl+shift+p 输入 Debug: Open launch.json 打开 launch.json 文件,如果第一次打开,会新建一个配置文件,默认配置内容如下
    
    {
        "version": "0.2.0",
        "configurations": [
            {
                "name": "Launch",
                "type": "go",
                "request": "launch",
                "mode": "auto",
                "program": "${fileDirname}",
                "env": {},
                "args": []
            }
        ]
    }
    常见属性如下
    
    属性    介绍
    name    调试界面下拉选择项的名称
    type    设置为go无需改动,是 vs code 用于计算调试代码需要用哪个扩展
    mode    可以设置为 auto, debug, remote, test, exec 中的一个
    program    调试程序的路径(绝对路径)
    env    调试时使用的环境变量。例如:{ "ENVNAME": "ENVVALUE" }
    envFile    包含环境变量文件的绝对路径,在 env 中设置的属性会覆盖 envFile 中的配置
    args    传给正在调试程序命令行参数数组
    showLog    布尔值,是否将调试信息输出
    logOutput    配置调试输出的组件(debugger, gdbwire, lldbout, debuglineerr, rpc),使用,分隔, showLog 设置为 true 时,此项配置生效
    buildFlags    构建 go 程序时传给 go 编译器的标志
    remotePath    远程调试程序的绝对路径,当 mode 设置为 remote 时有效
    在 debug 配置中使用 VS Code 变量
    ${workspaceFolder} 调试 VS Code 打开工作空间的根目录下的所有文件
    ${file} 调试当前文件
    ${fileDirname} 调试当前文件所在目录下的所有文件

    ############################################

  • 相关阅读:
    Asp.net MVC 视图引擎集合
    技术债务管理计划
    Android应用程序反编译
    Managed Extensibility Framework(MEF) 2 框架新特性介绍
    企业搜索引擎开发之连接器connector(十四)
    企业搜索引擎开发之连接器connector(十)
    企业搜索引擎开发之连接器connector(十一)
    zookeeper 原理
    企业搜索引擎开发之连接器connector(十二)
    jspf插件框架
  • 原文地址:https://www.cnblogs.com/igoodful/p/14066750.html
Copyright © 2020-2023  润新知