From 394a73c75feca441ee61920e8b918c27e27f30eb Mon Sep 17 00:00:00 2001 From: luxueyan Date: Fri, 14 Jun 2019 14:43:02 +0800 Subject: [PATCH] fix orm datarace --- orm/models_boot.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/orm/models_boot.go b/orm/models_boot.go index badfd11b..456e5896 100644 --- a/orm/models_boot.go +++ b/orm/models_boot.go @@ -335,11 +335,11 @@ func RegisterModelWithSuffix(suffix string, models ...interface{}) { // BootStrap bootstrap models. // make all model parsed and can not add more models func BootStrap() { + modelCache.Lock() + defer modelCache.Unlock() if modelCache.done { return } - modelCache.Lock() - defer modelCache.Unlock() bootStrap() modelCache.done = true }