MCPcopy
hub / github.com/TarsCloud/TarsGo / genStructDefine

Method genStructDefine

tars/tools/tars2go/gencode/gen_go.go:437–449  ·  view source on GitHub ↗
(st *ast.Struct)

Source from the content-addressed store, hash-verified

435}
436
437func (g *GenGo) genStructDefine(st *ast.Struct) {
438 g.P("// ", st.Name, " struct implement")
439 g.P("type ", st.Name, " struct {")
440 for _, v := range st.Mb {
441 tarsTag := `tars:"` + v.OriginKey + `,tag:` + strconv.Itoa(int(v.Tag)) + `,require:` + strconv.FormatBool(v.Require) + `"`
442 if g.opt.JsonOmitEmpty {
443 g.P(v.Key, " ", g.genType(v.Type), " `json:\"", v.OriginKey, ",omitempty\" ", tarsTag, "`")
444 } else {
445 g.P(v.Key, " ", g.genType(v.Type), " `json:\"", v.OriginKey, "\" ", tarsTag, "`")
446 }
447 }
448 g.P("}")
449}
450
451func (g *GenGo) genFunResetDefault(st *ast.Struct) {
452 g.P("func (st *", st.Name, ") ResetDefault() {")

Callers 1

genStructMethod · 0.95

Calls 2

PMethod · 0.95
genTypeMethod · 0.95

Tested by

no test coverage detected