工具
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.

25 lines
763 B

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. apiTmpl = CreateTpl("servicegen/tpl/api.tpl")
  9. apiPreTmpl = CreateTpl("servicegen/tpl/api_task.tpl")
  10. apiTaskTmpl = CreateTpl("servicegen/tpl/api_task.tpl")
  11. apiTestTmpl = CreateTpl("servicegen/tpl/api_test.tpl")
  12. dbModelTmpl = CreateTpl("servicegen/tpl/db_model.tpl")
  13. optionsTmpl = CreateTpl("servicegen/tpl/options.tpl")
  14. externalTmpl = CreateTpl("servicegen/tpl/external.tpl")
  15. )
  16. func CreateTpl(filename string)*template.Template {
  17. body, err := tpl.Asset(filename)
  18. //body, err := ioutil.ReadFile(filename)
  19. if err != nil {
  20. panic(err)
  21. }
  22. return template.Must(template.New(filepath.Base(filename)).Parse(string(body)))
  23. }