工具
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

28 lines
820 B

4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
  1. package servicegen
  2. import (
  3. "git.ouxuan.net/tommy/hasaki-ctl/servicegen/tpl"
  4. "path/filepath"
  5. "text/template"
  6. )
  7. var (
  8. apiTpl = CreateTpl("api.tpl")
  9. apiPreTpl = CreateTpl("api_pre.tpl")
  10. apiTaskTpl = CreateTpl("api_task.tpl")
  11. apiTestTpl = CreateTpl("api_test.tpl")
  12. dbModelTpl = CreateTpl("db_model.tpl")
  13. optionsTpl = CreateTpl("options.tpl")
  14. externalTpl = CreateTpl("external.tpl")
  15. configJsonTpl = CreateTpl("configjson.tpl")
  16. mainTpl = CreateTpl("main.tpl")
  17. initializeTpl = CreateTpl("initialize.tpl")
  18. adminInitializeTpl = CreateTpl("initialize_admin.tpl")
  19. )
  20. func CreateTpl(filename string)*template.Template {
  21. body, err := tpl.Asset(filepath.Join("servicegen/tpl", filename))
  22. if err != nil {
  23. panic(err)
  24. }
  25. return template.Must(template.New(filepath.Base(filename)).Parse(string(body)))
  26. }