go run main.go
风.foxwho
编译 执行时候报错
# github.com/foxiswho/fox-shop/models
/Users/fox/go/gopath/src/github.com/foxiswho/fox-shop/models/admin.go:53:40: cannot declare name db.Query
/Users/fox/go/gopath/src/github.com/foxiswho/fox-shop/models/admin.go:55:3: cannot use db.Query (type *db.QuerySession) as type *db.Paginator in return argument
/Users/fox/go/gopath/src/github.com/foxiswho/fox-shop/models/admin.go:58:2: cannot use db.Query (type *db.QuerySession) as type *db.Paginator in return argument
部分代码
package models
import (
"time"
"fmt"
. "github.com/foxiswho/fox-shop/module/db"
"github.com/foxiswho/fox-shop/module"
)
原因:Query
这个自定义变量,与 module/db
的 db.Query
这个变量冲突,因为时使用 特殊的 点号引入
解决方法:直接报错的位置,把变量名称修改与Query
不同的名字