From fc62745b4f6c836af0acb1e2bd30ce81d7aac5b0 Mon Sep 17 00:00:00 2001 From: ZhengYang Date: Mon, 4 Aug 2014 16:08:46 +0800 Subject: [PATCH] remove defer close file --- g_models.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/g_models.go b/g_models.go index de1db2b..f33cbcc 100644 --- a/g_models.go +++ b/g_models.go @@ -443,7 +443,6 @@ func writeModelFiles(tables []*Table, mPath string) { ColorLog("[ERRO] %v\n", err) os.Exit(2) } - defer f.Close() template := "" if tb.Pk == "" { template = STRUCT_MODEL_TPL @@ -456,6 +455,7 @@ func writeModelFiles(tables []*Table, mPath string) { ColorLog("[ERRO] Could not write model file to %s\n", fpath) os.Exit(2) } + f.Close() ColorLog("[INFO] model => %s\n", fpath) formatAndFixImports(fpath) } @@ -474,12 +474,12 @@ func writeControllerFiles(tables []*Table, cPath string) { ColorLog("[ERRO] %v\n", err) os.Exit(2) } - defer f.Close() fileStr := strings.Replace(CTRL_TPL, "{{ctrlName}}", camelCase(tb.Name), -1) if _, err := f.WriteString(fileStr); err != nil { ColorLog("[ERRO] Could not write controller file to %s\n", fpath) os.Exit(2) } + f.Close() ColorLog("[INFO] controller => %s\n", fpath) formatAndFixImports(fpath) } @@ -507,11 +507,11 @@ func writeRouterFile(tables []*Table, rPath string) { ColorLog("[ERRO] %v\n", err) os.Exit(2) } - defer f.Close() if _, err := f.WriteString(routerStr); err != nil { ColorLog("[ERRO] Could not write router file to %s\n", fpath) os.Exit(2) } + f.Close() ColorLog("[INFO] router => %s\n", fpath) formatAndFixImports(fpath) }