Add new LemmyTime type and remove omitempty from json tag

This commit is contained in:
2023-01-05 13:42:24 -08:00
parent 187da56546
commit 1765ca2db5
32 changed files with 1262 additions and 1276 deletions

View File

@@ -24,15 +24,8 @@ func (s *StructGenerator) Generate(items []parser.Item) error {
st := item.Struct
f.Type().Id(st.Name).StructFunc(func(g *jen.Group) {
for _, field := range st.Fields {
var t jen.Code
if field.Type == "time.Time" {
t = jen.Qual("time", "Time")
} else {
t = jen.Id(field.Type)
}
g.Id(field.Name).Add(t).Tag(map[string]string{
"json": field.OrigName + ",omitempty",
g.Id(field.Name).Id(field.Type).Tag(map[string]string{
"json": field.OrigName,
"url": field.OrigName + ",omitempty",
})
}