【问题标题】:Glide package manager usageGlide 包管理器使用
【发布时间】:2017-02-09 00:57:27
【问题描述】:

我正在使用Glide 来管理我的 golang 依赖项,但是当我尝试在干净的环境中构建我的项目时,vendor 目录被忽略了:

./glide install
[INFO]  Downloading dependencies. Please wait...
[INFO]  --> Found desired version locally github.com/dustin/go-humanize 7a41df006ff9af79a29f0ffa9c5f21fbe6314a2d!
[INFO]  --> Found desired version locally github.com/jaxxstorm/flexvolume b65378104ef0f49af77d6f73d87da7e78d0f8252!
[INFO]  --> Found desired version locally github.com/kolyshkin/goploop-cli 5365b446a713e31ac4f2026b05a6dac27bbdf21c!
[INFO]  --> Found desired version locally github.com/urfave/cli 0bdeddeeb0f650497d603c4ad7b20cfe685682f6!
[INFO]  Setting references.
[INFO]  --> Setting version for github.com/kolyshkin/goploop-cli to 5365b446a713e31ac4f2026b05a6dac27bbdf21c.
[INFO]  --> Setting version for github.com/dustin/go-humanize to 7a41df006ff9af79a29f0ffa9c5f21fbe6314a2d.
[INFO]  --> Setting version for github.com/urfave/cli to 0bdeddeeb0f650497d603c4ad7b20cfe685682f6.
[INFO]  --> Setting version for github.com/jaxxstorm/flexvolume to b65378104ef0f49af77d6f73d87da7e78d0f8252.
[INFO]  Exporting resolved dependencies...
[INFO]  --> Exporting github.com/urfave/cli
[INFO]  --> Exporting github.com/jaxxstorm/flexvolume
[INFO]  --> Exporting github.com/dustin/go-humanize
[INFO]  --> Exporting github.com/kolyshkin/goploop-cli
[INFO]  Replacing existing vendor dependencies

所有的供应商部门都在那里

vendor
└── github.com
    ├── dustin
    │   └── go-humanize
    ├── jaxxstorm
    │   └── flexvolume
    ├── kolyshkin
    │   └── goploop-cli
    └── urfave
        └── cli
            ├── altsrc
        └── autocomplete

11 个目录

但我的项目仍然忽略了供应商目录:

go build -o ploop main.go
    main.go:4:2: cannot find package "github.com/jaxxstorm/flexvolume" in any of:
        /usr/lib/golang/src/github.com/jaxxstorm/flexvolume (from $GOROOT)
        /tmp/go/src/github.com/jaxxstorm/flexvolume (from $GOPATH)
    main.go:7:2: cannot find package "github.com/kolyshkin/goploop-cli" in any of:
        /usr/lib/golang/src/github.com/kolyshkin/goploop-cli (from $GOROOT)
        /tmp/go/src/github.com/kolyshkin/goploop-cli (from $GOPATH)
    main.go:8:2: cannot find package "github.com/urfave/cli" in any of:
        /usr/lib/golang/src/github.com/urfave/cli (from $GOROOT)
        /tmp/go/src/github.com/urfave/cli (from $GOPATH)

我认为我不需要设置GOVENDOREXPERIMENT,因为我使用的是go1.7.4

【问题讨论】:

  • 你不是在构建一个包,你只是在构建一个文件。通过其导入路径或从主包目录构建或安装您的包。
  • 抱歉,没关注这里,能详细点吗?
  • 在您的项目中输入 go build full/import/pathgo build
  • 恐怕没什么区别 :(

标签: go glide-golang


【解决方案1】:

真的很愚蠢,git repo 也需要在$GOPATH 中。我将我的 repo 符号链接到 $GOPATH/src/github.com/vendor/project 并且一切正常。

【讨论】:

  • 不要在你的 GOPATH 中使用符号链接。在许多情况下,构建工具会忽略符号链接。只需遵循文档:golang.org/doc/code.html
猜你喜欢
  • 1970-01-01
  • 2016-04-18
  • 2018-02-15
  • 1970-01-01
  • 1970-01-01
  • 2015-02-01
  • 2017-09-30
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多