entc/gen: adding tagLookup / strings.Split functions to template engine

Signed-off-by: Alex Snast <alexsn@fb.com>
This commit is contained in:
Alex Snast
2020-01-23 14:57:52 +02:00
parent 6819c01906
commit b840ea3f81

View File

@@ -51,6 +51,8 @@ var (
"trimPackage": trimPackage,
"xtemplate": xtemplate,
"hasTemplate": hasTemplate,
"split": strings.Split,
"tagLookup": tagLookup,
}
rules = ruleset()
acronym = make(map[string]bool)
@@ -306,3 +308,9 @@ func indirect(v reflect.Value) reflect.Value {
}
return v
}
// tagLookup returns the value associated with key in the tag string.
func tagLookup(tag, key string) string {
v, _ := reflect.StructTag(tag).Lookup(key)
return v
}