fatih / structs

Utilities for Go structs

Home Page:http://godoc.org/github.com/fatih/structs

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Map() time.Time

MartinBrugnara opened this issue · comments

time.Time is converted to an empty map.

What do you expect? Can you give me your test data and the expected data you want have?

Btw, did you tested it with omitnested tag field, like

type Foo struct {
    Time time.Time     `structs:"time,omitnested"`
}

No, I haven't tried with omitnested.

My struct is:

type User struct {
    Uid       int       `json:"uid" db:"uid"`               // RO
    Email     string    `json:"email" db:"email"`           // 250
    FirstName string    `json:"first_name" db:"first_name"` // 50
    LastName  string    `json:"last_name" db:"last_name"`   // 50
    IsEnabled bool      `json:"is_enabled" db:"is_enabled"` // RO | W only super user
    Creation  time.Time `json:"creation" db:"creation"`     // RO
    LastLogin time.Time `json:"last_login" db:"last_login"` // RO
}

Ok can you try please the omitnested tag ? Like:

type User struct {
    Uid       int       `json:"uid" db:"uid"`               // RO
    Email     string    `json:"email" db:"email"`           // 250
    FirstName string    `json:"first_name" db:"first_name"` // 50
    LastName  string    `json:"last_name" db:"last_name"`   // 50
    IsEnabled bool      `json:"is_enabled" db:"is_enabled"` // RO | W only super user
    Creation  time.Time `json:"creation" db:"creation" structs:",omitnested"`     // RO
    LastLogin time.Time `json:"last_login" db:"last_login" structs:",omitnested"` // RO
}

structs:",omitnested" tag makes it work thanks =)

I was too lazy to read the full doc.. sorry