如何在go dep项目中将go模块用作依赖项?

时间:2019-05-12 17:01:48

标签: go dependency-management package-managers go-modules godeps

我有Go dep项目。我想使用go模块作为依赖项。例如。我需要这个 https://github.com/pion/webrtc

因此,我尝试在 Gopkg.toml 中声明这种依赖关系:

[[constraint]]
  name = "github.com/pion/webrtc"
  revision = "6a0b7020b1724dcb302ddfadab0c80fabc144c97"

我做dep ensure时遇到错误:

Solving failure: No versions of github.com/pion/webrtc met constraints:
        6a0b7020b1724dcb302ddfadab0c80fabc144c97: "github.com/pion/webrtc" imports "github.com/pion/webrtc/v2/pkg/rtcerr", which con
tains malformed code: no package exists at "github.com/pion/webrtc/v2/pkg/rtcerr"
        v2.0.14: Could not introduce github.com/pion/webrtc@v2.0.14, as it is not allowed by constraint 6a0b7020b1724dcb302ddfadab0c
80fabc144c97 from project ***.
        v2.0.13: Could not introduce github.com/pion/webrtc@v2.0.13, as it is not allowed by constraint 6a0b7020b1724dcb302ddfadab0c
80fabc144c97 from project ***.

问题似乎与库的 2版本有关。当它是 1 时,一切正常。

1 个答案:

答案 0 :(得分:2)

感谢使用Pion:)

我们在Pion WebRTC问题跟踪器上打开了相同的issue。有PR可以解决这种情况下的问题。

如果可能的话,我会切换到模块,但与此同时希望使用此补丁版本的dep应该会有所帮助!