dstobkpm908182 2016-11-21 07:58
浏览 1750
已采纳

为每个vscode项目设置`GOPATH`

Setting the GOPATH variable global as an enviroment variable works fine with Visual Studio Code.

But setting a project specific variable globally doesn't seem very nice to me. Consider you have multiple Go projects, you would have to change this variable each time you, compile, debug, ... etc. a project.

Is there a possibility to set the GOPATH variable as a project variable in Visual Studio Code? Ether in settings.json or launch.json?

  • 写回答

4条回答 默认 最新

  • dqknycyt92288 2016-11-21 09:03
    关注

    Go 1.5 added the vendor directory that allows a per-project dependency management.

    If there is a source directory d/vendor, then, when compiling a source file within the subtree rooted at d, import "p" is interpreted as import "d/vendor/p" if that path names a directory containing at least one file with a name ending in “.go”.

    source

    This feature has been enabled by default with Go 1.6:

    Go 1.5 introduced experimental support for a “vendor” directory that was enabled by an environment variable. In Go 1.6, the feature is now enabled by default.

    source

    Even with the 1.6 version, depending on the tools you use, you might need to set the GO15VENDOREXPERIMENT environment variable to 1 (export GO15VENDOREXPERIMENT=1 on unix-based OS)

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(3条)

报告相同问题?

悬赏问题

  • ¥15 网络科学导论,网络控制
  • ¥15 metadata提取的PDF元数据,如何转换为一个Excel
  • ¥15 关于arduino编程toCharArray()函数的使用
  • ¥100 vc++混合CEF采用CLR方式编译报错
  • ¥15 coze 的插件输入飞书多维表格 app_token 后一直显示错误,如何解决?
  • ¥15 vite+vue3+plyr播放本地public文件夹下视频无法加载
  • ¥15 c#逐行读取txt文本,但是每一行里面数据之间空格数量不同
  • ¥50 如何openEuler 22.03上安装配置drbd
  • ¥20 ING91680C BLE5.3 芯片怎么实现串口收发数据
  • ¥15 无线连接树莓派,无法执行update,如何解决?(相关搜索:软件下载)