我在Golang中使用wgo进行依赖管理(虽然我认为 wgo 与此关系不大),wgo 的文件夹结构是这样的
project/
.gocfg/
gopaths
vendor.json
vendor/
src/
github.com_or_whatever/
我有一个自己编写的库,它nsq-go在导出的方法之一中使用了一种类型:
func AddNsqSubscription(
topic, channel string,
handler nsq.Handler,
config *nsq.Config) error { }
图书馆被调用messi,我nsq-go像这样导入"messi/vendor/src/github.com/bitly/go-nsq"
当我尝试在另一个项目中使用这个库时,问题就出现了。例如,在一个名为scribe我的项目中,有以下代码(注意导入):
import (
"scribe/vendor/src/github.com/bitly/go-nsq"
"scribe/vendor/src/messi"
)
//...
nsqHandler := nsq.HandlerFunc(func(message *nsq.Message) error {
msgHandler(MessiMessage{message})
return nil
})
return messi.AddNsqSubscription(destination, subdestination, nsqHandler, nsq.NewConfig())
当我go build返回以下错误时:
不能使用nsqHandler(类型“ scribe /vendor/src/github.com/bitly/go-nsq”.HandlerFunc)作为类型“ messi /vendor/src/github.com/bitly/go-nsq”.Handler 在参数中给 messi .AddNsqSubscription: "scribe/vendor/src/github.com/bitly/go-nsq".HandlerFunc 没有实现 "messi/vendor/src/github.com/bitly/go-nsq".Handler(HandleMessage 方法类型错误)
有HandleMessage( " scribe /vendor/src/github.com/bitly/go-nsq".Message) 错误
想要HandleMessage( " messi /vendor/src/github.com/bitly/go-nsq".Message) 错误
为什么?我真的不知道发生了什么。go-nsq导入的代码完全一样,但是golang要这个代码来自同一个文件夹?
我究竟做错了什么?
慕标5832272
相关分类