func (g *tsGen) genContent(tpl *template.Template, data tsStruct) string {
	buf := bytes.NewBufferString("")
	err := tpl.Execute(buf, data)
	if err != nil {
		panic(err)
	}
	return buf.String()
}
load CONTENT into TEMPLATE
package output
import (
	"bytes"
	"fmt"
	"strings"
	"text/template"
	"unicode"
	plugin "github.com/golang/protobuf/protoc-gen-go/plugin"
	"github.com/yoozoo/protoapi/generator/data"
	"github.com/yoozoo/protoapi/util"
)
var tsTypes = map[string]string{
	"int":      "number",
	"float64":  "number",
	"float":    "number",
	"int32":    "number",
	"int64":    "number",
	"uint32":   "number",
	"uint64":   "number",
	"sint32":   "number",
	"sint64":   "number",
	"fixed32":  "number",
	"fixed64":  "number",
	"sfixed32": "number",
	"sfixed64": "number",
	"bool":     "boolean",
	"string":   "string",
}
type tsGen struct {
	DataTypes []*data.MessageData
	Lib       tsLibs
	objsFile   string
	helperFile string
	axiosFile  string
	fetchFile  string
	wechatFile string
	objsTpl          *template.Template
	helperTpl        *template.Template
	fetchHelperTpl   *template.Template
	helperCommonsTpl *template.Template
	axiosTpl  *template.Template
	fetchTpl  *template.Template
	wechatTpl *template.Template
	service *data.ServiceData
}
type tsStruct struct {
	ClassName string
	DataTypes []*data.MessageData
	Enums     []*data.EnumData
	Functions []*data.Method
	Gen       *tsGen
}
func toTypeScriptType(dataType string) string {
	if primaryType, ok := tsTypes[dataType]; ok {
		return primaryType
	}
	return dataType
}
func getErrorType(options data.OptionMap) string {
	if errType, ok := options["error"]; ok {
		return errType
	}
	return ""
}
func getServiceMtd(options data.OptionMap) string {
	if servMtd, ok := options["service_method"]; ok {
		return servMtd
	}
	return "POST"
}
func getImportDataTypes(mtds []*data.Method) map[string]bool {
	res := make(map[string]bool)
	for _, mtd := range mtds {
		_, exist := res[mtd.InputType]
		if !exist {
			res[mtd.InputType] = true
		}
		_, exist = res[mtd.OutputType]
		if !exist {
			res[mtd.OutputType] = true
		}
	}
	return res
}
func isCommonError(name string) bool {
	if strings.HasSuffix(name, "Error") && !strings.Contains(name, "Field") && !strings.Contains(name, "Common") {
		return true
	}
	return false
}
func lowerInital(str string) string {
	for i, v := range str {
		return string(unicode.ToLower(v)) + str[i+1:]
	}
	return ""
}
func getCommonErrorName(name string) string {
	if strings.HasSuffix(name, "Error") && !strings.Contains(name, "Field") && !strings.Contains(name, "Common") {
		return "\"" + lowerInital(name) + "\""
	}
	return ""
}
func genFileName(packageName string, fileName string) string {
	return fileName + ".ts"
}
func (g *tsGen) loadTpl() {
	g.axiosTpl = g.getTpl("/generator/template/ts/service_axios.gots")
	g.fetchTpl = g.getTpl("/generator/template/ts/service_fetch.gots")
	g.wechatTpl = g.getTpl("/generator/template/ts/service_wechat.gots")
	g.objsTpl = g.getTpl("/generator/template/ts/objs.gots")
	g.helperTpl = g.getTpl("/generator/template/ts/helper.gots")
	g.fetchHelperTpl = g.getTpl("/generator/template/ts/helper_fetch.gots")
	g.helperCommonsTpl = g.getTpl("/generator/template/ts/helper_common_partials.gots")
}
func (g *tsGen) getTpl(path string) *template.Template {
	var funcs = template.FuncMap{
		"tsType":             toTypeScriptType,
		"toLower":            strings.ToLower,
		"isCommonError":      isCommonError,
		"getCommonErrorName": getCommonErrorName,
		"getErrorType":       getErrorType,
		"getServiceMtd":      getServiceMtd,
		"getImportDataTypes": getImportDataTypes,
	}
	var err error
	tpl := template.New("tpl").Funcs(funcs)
	tplStr := data.LoadTpl(path)
	result, err := tpl.Parse(tplStr)
	if err != nil {
		panic(err)
	}
	return result
}