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条)

报告相同问题?