mirror of
https://github.com/zeromicro/go-zero.git
synced 2025-01-24 17:52:49 +08:00
41964f9d52
* model/rpc generate code from template cache * delete unused(deprecated) code * support template init|update|clean|revert * model: return the execute result for insert and update operation * // deprecated: containsAny * add template test * add default buildVersion * update build version
39 lines
852 B
Go
39 lines
852 B
Go
package gen
|
|
|
|
import (
|
|
"github.com/tal-tech/go-zero/tools/goctl/model/sql/template"
|
|
"github.com/tal-tech/go-zero/tools/goctl/util"
|
|
)
|
|
|
|
func genImports(withCache, timeImport bool) (string, error) {
|
|
if withCache {
|
|
text, err := util.LoadTemplate(category, importsTemplateFile, template.Imports)
|
|
if err != nil {
|
|
return "", err
|
|
}
|
|
|
|
buffer, err := util.With("import").Parse(text).Execute(map[string]interface{}{
|
|
"time": timeImport,
|
|
})
|
|
if err != nil {
|
|
return "", err
|
|
}
|
|
|
|
return buffer.String(), nil
|
|
} else {
|
|
text, err := util.LoadTemplate(category, importsWithNoCacheTemplateFile, template.ImportsNoCache)
|
|
if err != nil {
|
|
return "", err
|
|
}
|
|
|
|
buffer, err := util.With("import").Parse(text).Execute(map[string]interface{}{
|
|
"time": timeImport,
|
|
})
|
|
if err != nil {
|
|
return "", err
|
|
}
|
|
|
|
return buffer.String(), nil
|
|
}
|
|
}
|