mirror of
https://github.com/astaxie/beego.git
synced 2024-11-22 12:50:55 +00:00
improvement the error if use &&Struct
This commit is contained in:
parent
7df74c0a30
commit
aa091cea42
@ -57,11 +57,11 @@ var (
|
|||||||
|
|
||||||
// model info collection
|
// model info collection
|
||||||
type _modelCache struct {
|
type _modelCache struct {
|
||||||
sync.RWMutex
|
sync.RWMutex // only used outsite for bootStrap
|
||||||
orders []string
|
orders []string
|
||||||
cache map[string]*modelInfo
|
cache map[string]*modelInfo
|
||||||
cacheByFN map[string]*modelInfo
|
cacheByFN map[string]*modelInfo
|
||||||
done bool
|
done bool
|
||||||
}
|
}
|
||||||
|
|
||||||
// get all model info
|
// get all model info
|
||||||
|
@ -32,6 +32,9 @@ func registerModel(prefix string, model interface{}) {
|
|||||||
if val.Kind() != reflect.Ptr {
|
if val.Kind() != reflect.Ptr {
|
||||||
panic(fmt.Errorf("<orm.RegisterModel> cannot use non-ptr model struct `%s`", getFullName(typ)))
|
panic(fmt.Errorf("<orm.RegisterModel> cannot use non-ptr model struct `%s`", getFullName(typ)))
|
||||||
}
|
}
|
||||||
|
if typ.Kind() == reflect.Ptr {
|
||||||
|
panic(fmt.Errorf("<orm.RegisterModel> only allow ptr model struct, it looks you use two reference to the struct `%s`", typ))
|
||||||
|
}
|
||||||
|
|
||||||
table := getTableName(val)
|
table := getTableName(val)
|
||||||
|
|
||||||
@ -320,7 +323,6 @@ func BootStrap() {
|
|||||||
if modelCache.done {
|
if modelCache.done {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
modelCache.Lock()
|
modelCache.Lock()
|
||||||
defer modelCache.Unlock()
|
defer modelCache.Unlock()
|
||||||
bootStrap()
|
bootStrap()
|
||||||
|
Loading…
Reference in New Issue
Block a user