我试着用这个Golang Yelp API package.在一些 struct 中,它使用guregu's null package中定义的类型.
我想声明一个在Yelp API包中定义的 struct ,其中一些字段的值为null.Float
(i.e. this struct, which im trying to use).因此,在我的程序中,我导入了Yelp API包和guregu的null包,并try 声明struct,其中ip.Lat和ip.Lat为float64s.(null.FloatFrom
definition):
33 locationOptions := yelp.LocationOptions{
34 ip.Zip,
35 &yelp.CoordinateOptions{
36 Latitude: null.FloatFrom(ip.Lat),
37 Longitude: null.FloatFrom(ip.Lon),
38 },
39 }
但当我运行程序时,它告诉我:
./cli.go:36: cannot use "github.com/guregu/null".FloatFrom(ip.Lat) (type
"github.com/guregu/null".Float) as type "github.com/JustinBeckwith/go-
yelp/yelp/vendor/github.com/guregu/null".Float in field value
我试了两件事:
1) 我没有导入null
包,这导致Go抱怨null
未定义.2) 我还try 直接导入供应商提供的软件包,这导致Go告诉我use of vendored package not allowed
.
你有什么办法解决这个问题吗?