dateparse_tag/parse_test.go

27 lines
399 B
Go
Raw Normal View History

2022-01-12 14:11:27 +08:00
package dateparse_tag
import (
"testing"
"time"
)
type User struct {
Name string `json:"name"`
BirthDay string `json:"birth_day" format_date:"default"`
}
func TestNewDateParseTag(t *testing.T) {
u := new(User)
u.Name = "张三"
u.BirthDay = time.Now().String()
2022-01-12 14:38:39 +08:00
t.Logf("user : %v", u)
2022-01-12 14:11:27 +08:00
dp := NewDateParseTag(WithTagName("format_date"))
dp.Parse(u, u)
2022-01-12 14:38:39 +08:00
t.Logf("user new %v", u)
2022-01-12 14:11:27 +08:00
}