我从当前文件中调用对象是有效的 (我正在创建单元测试)
type Requires struct {
Name string `yaml:"name,omitempty"`
}
我在测试中称之为
Requires: []Requires{
{
Name: "db",
}
哪作得好,
现在我将<{1}}结构移动到不同的包模型
我尝试将其称为
Requires
无法使用models.require类型
Requires: models.Requires{ { Name: "db", }
还尝试使用[]Require
这给我错误
使用没有选择器错误的包
Getting a use of package without selector error
但不确定如何处理我的情况...
知道如何克服这个问题吗?
更新
当我按照
进行尝试时models.[]Requires
我收到了错误
不能使用models.Requires literal(type models.Requires)作为类型 [] models.Requires in field value
这是粘胶的错误
答案 0 :(得分:2)
包是models
,其中包含用作切片的Requires
结构。查看Qualified identifiers以了解更多关于包的工作原理。
在您的情况下,它需要Requires
models
个Requires: []models.Requires{
{
Name: "db",
}
包,应按如下方式使用:
multiDexEnabled true