| 435 | } |
| 436 | |
| 437 | func (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 | |
| 451 | func (g *GenGo) genFunResetDefault(st *ast.Struct) { |
| 452 | g.P("func (st *", st.Name, ") ResetDefault() {") |