我使用dep
来管理Go项目中的依赖项。
我在~/go/src/github.com/my-repo/myproject
中有一个简单的项目,只有一个文件example.go
:
package main
import (
tcrypto "github.com/tendermint/go-crypto"
"github.com/tendermint/tendermint/types"
)
type ExampleSigner struct{}
// Implements types.Signer
func (signer ExampleSigner) Sign(msg []byte) tcrypto.Signature {
return tcrypto.Signature{}
}
// Implements types.Signer
func (signer ExampleSigner) PubKey() tcrypto.PubKey {
return tcrypto.PubKey{}
}
func main() {
mySigner := ExampleSigner{}
validator := types.LoadPrivValidator("foo")
validator.SetSigner(mySigner)
}
运行dep init
,然后dep ensure
,然后go install
正常运行。 (运行代码不会做任何有意义的事情 - 这只是足以重现下面的编译错误的代码。)
现在,我想使用github.com/tendermint/tendermint
的修改版本,因此,根据the documentation,我已从./vendor
中删除了目录,并在$GOPATH
中修改了副本1}}:
~/go/src/github.com/tendermint/tendermint <---- (modified copy)
~/go/src/github.com/my-repo/myproject/vendor/github.com/tendermint/tendermint
^^^^^^^^^^
(I deleted this directory)
我现在得到以下编译错误,假设我已使用tendermint/tendermint
安装了glide install
个依赖项:
# github.com/my-repo/myproject
./example.go:25:21: cannot use mySigner (type ExampleSigner) as type "github.com/tendermint/tendermint/types".Signer in argument to validator.SetSigner:
ExampleSigner does not implement "github.com/tendermint/tendermint/types".Signer (wrong type for PubKey method)
have PubKey() "github.com/my-repo/myproject/vendor/github.com/tendermint/go-crypto".PubKey
want PubKey() "github.com/tendermint/tendermint/vendor/github.com/tendermint/go-crypto".PubKey
如果我删除了~/go/src/github.com/tendermint/tendermint/vendor
目录,我就会收到这些错误:
../../tendermint/tendermint/types/events.go:5:2: cannot find package "github.com/tendermint/abci/types" in any of:
/usr/local/go/src/github.com/tendermint/abci/types (from $GOROOT)
/home/djones/go/src/github.com/tendermint/abci/types (from $GOPATH)
../../tendermint/tendermint/types/genesis.go:10:2: cannot find package "github.com/tendermint/go-crypto" in any of:
/usr/local/go/src/github.com/tendermint/go-crypto (from $GOROOT)
/home/djones/go/src/github.com/tendermint/go-crypto (from $GOPATH)
../../tendermint/tendermint/types/block.go:11:2: cannot find package "github.com/tendermint/go-wire" in any of:
/usr/local/go/src/github.com/tendermint/go-wire (from $GOROOT)
/home/djones/go/src/github.com/tendermint/go-wire (from $GOPATH)
../../tendermint/tendermint/types/block.go:12:2: cannot find package "github.com/tendermint/go-wire/data" in any of:
/usr/local/go/src/github.com/tendermint/go-wire/data (from $GOROOT)
/home/djones/go/src/github.com/tendermint/go-wire/data (from $GOPATH)
../../tendermint/tendermint/types/block.go:13:2: cannot find package "github.com/tendermint/tmlibs/common" in any of:
/usr/local/go/src/github.com/tendermint/tmlibs/common (from $GOROOT)
/home/djones/go/src/github.com/tendermint/tmlibs/common (from $GOPATH)
../../tendermint/tendermint/types/events.go:8:2: cannot find package "github.com/tendermint/tmlibs/events" in any of:
/usr/local/go/src/github.com/tendermint/tmlibs/events (from $GOROOT)
/home/djones/go/src/github.com/tendermint/tmlibs/events (from $GOPATH)
../../tendermint/tendermint/types/priv_validator.go:15:2: cannot find package "github.com/tendermint/tmlibs/log" in any of:
/usr/local/go/src/github.com/tendermint/tmlibs/log (from $GOROOT)
/home/djones/go/src/github.com/tendermint/tmlibs/log (from $GOPATH)
../../tendermint/tendermint/types/block.go:14:2: cannot find package "github.com/tendermint/tmlibs/merkle" in any of:
/usr/local/go/src/github.com/tendermint/tmlibs/merkle (from $GOROOT)
/home/djones/go/src/github.com/tendermint/tmlibs/merkle (from $GOPATH)
有没有办法避免这些错误,而不必将修改后的tendermint/tendermint
提交到某处的回购并在source
中使用Gopkg.toml
?