gen
gen copied to clipboard
模型在多个目录下无法正确处理包引用
GORM Playground Link
https://github.com/go-gorm/playground/pull/1
Description
/mnt/c/Users/goodk/GolandProjects/gen-test 15s ❯ tree 21:44:40
.
├── a
│ └── model
│ └── models.go
├── b
│ └── model
│ └── models.go
├── go.mod
├── go.sum
├── main.go
└── query
├── as.gen.go
├── bs.gen.go
└── gen.go
// a/model/models.go
package model
type A struct {
ID uint
Name string
}
// b/model/models.go
package model
import (
"gen-test/a/model"
)
type B struct {
AID uint
A *model.A
Six string
}
b模型的gen文件因为使用b/model, 而b/model 没有 struct A 而报错
@goodking-bq try conf.WithImportPkgPath("gen-test/a/model")
@qqxhb thanks,but not work for me .
I have the same issue. May I ask if this issue has been resolved?
1, must use master branch
go get -u gorm.io/gen@master
2, use WithImportPkgPath
c := gen.Config{ ... }
c.WithImportPkgPath(
`a "gen-test/a/model"`,
`b "gen-test/b/model"`,
)
1, must use master branch
go get -u gorm.io/gen@master2, use WithImportPkgPath
c := gen.Config{ ... } c.WithImportPkgPath( `a "gen-test/a/model"`, `b "gen-test/b/model"`, )
i tried, but not work ,why? repo