|
|
@@ -1,8 +1,11 @@
|
|
|
package main
|
|
|
|
|
|
import (
|
|
|
+ "bufio"
|
|
|
"go-create/configs"
|
|
|
"go-create/util"
|
|
|
+ "html/template"
|
|
|
+ "os"
|
|
|
)
|
|
|
|
|
|
func init() {
|
|
|
@@ -16,6 +19,24 @@ func main() {
|
|
|
//util.MysqlToDao()
|
|
|
//util.MysqlToBaseCRUDRouter()
|
|
|
//执行生成,vue
|
|
|
- util.MysqlToVueApi()
|
|
|
+ //util.MysqlToVueApi()
|
|
|
+ LoadStructTemplate("E:\\project\\kkc\\go-xorm-create\\domain\\DoMain.go")
|
|
|
+}
|
|
|
+
|
|
|
+// LoadStructTemplate 加载结构体生成模板
|
|
|
+func LoadStructTemplate(url string) {
|
|
|
+ os.Truncate(url, 0)
|
|
|
+ file, _ := os.OpenFile(url, os.O_CREATE|os.O_RDWR, 0666)
|
|
|
+ defer file.Close()
|
|
|
+
|
|
|
+ writer := bufio.NewWriter(file)
|
|
|
|
|
|
+ tmpl, err := template.ParseFiles("./tmpl/sturct.go.template")
|
|
|
+ if err != nil {
|
|
|
+ panic(err)
|
|
|
+ }
|
|
|
+ err = tmpl.Execute(writer, util.MTables)
|
|
|
+ if err != nil {
|
|
|
+ panic(err)
|
|
|
+ }
|
|
|
}
|