From 82b7ab3e310e63a408b318a62eb736a79f367aac Mon Sep 17 00:00:00 2001 From: ZhengYang Date: Tue, 19 Aug 2014 17:43:08 +0800 Subject: [PATCH 1/2] import package for no-pk models --- g_appcode.go | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/g_appcode.go b/g_appcode.go index 0d04c82..b99b26c 100644 --- a/g_appcode.go +++ b/g_appcode.go @@ -487,10 +487,13 @@ func writeModelFiles(tables []*Table, mPath string, selectedTables map[string]bo fileStr = strings.Replace(fileStr, "{{modelName}}", camelCase(tb.Name), -1) // if table contains time field, import time.Time package timePkg := "" + importTimePkg := "" if tb.ImportTimePkg { timePkg = "\"time\"\n" + importTimePkg = "import \"time\"\n" } fileStr = strings.Replace(fileStr, "{{timePkg}}", timePkg, -1) + fileStr = strings.Replace(fileStr, "{{importTimePkg}}", importTimePkg, -1) if _, err := f.WriteString(fileStr); err != nil { ColorLog("[ERRO] Could not write model file to %s\n", fpath) os.Exit(2) @@ -707,6 +710,7 @@ func getPackagePath(curpath string) (packpath string) { const ( STRUCT_MODEL_TPL = `package models +{{importTimePkg}} {{modelStruct}} ` From 9e2699dbd6ad896bcd82b2fbef63aea8e41522cd Mon Sep 17 00:00:00 2001 From: ZhengYang Date: Tue, 19 Aug 2014 17:47:29 +0800 Subject: [PATCH 2/2] minor fomatting --- g_appcode.go | 1 - 1 file changed, 1 deletion(-) diff --git a/g_appcode.go b/g_appcode.go index b99b26c..cfca8be 100644 --- a/g_appcode.go +++ b/g_appcode.go @@ -711,7 +711,6 @@ func getPackagePath(curpath string) (packpath string) { const ( STRUCT_MODEL_TPL = `package models {{importTimePkg}} - {{modelStruct}} `