502c898d75
* binding: support unix time ref:#1979 * binding: support unix time add test file modify readme ```golang package main import ( "fmt" "github.com/gin-gonic/gin" "time" ) type shareTime struct { CreateTime time.Time `form:"createTime" time_format:"unixNano"` UnixTime time.Time `form:"unixTime" time_format:"unix"` } func main() { r := gin.Default() unix := r.Group("/unix") testCT := time.Date(2019, 7, 6, 16, 0, 33, 123, time.Local) fmt.Printf("%d\n", testCT.UnixNano()) testUT := time.Date(2019, 7, 6, 16, 0, 33, 0, time.Local) fmt.Printf("%d\n", testUT.Unix()) unix.GET("/nano", func(c *gin.Context) { s := shareTime{} c.ShouldBindQuery(&s) if !testCT.Equal(s.CreateTime) { c.String(500, "want %d got %d", testCT.UnixNano(), s.CreateTime) return } c.JSON(200, s) }) unix.GET("/sec", func(c *gin.Context) { s := shareTime{} c.ShouldBindQuery(&s) if !testUT.Equal(s.UnixTime) { c.String(500, "want %d got %d", testCT.Unix(), s.UnixTime) return } c.JSON(200, s) }) r.Run() } ``` * Contraction variable scope |
||
---|---|---|
.. | ||
binding_body_test.go | ||
binding_test.go | ||
binding.go | ||
default_validator.go | ||
form_mapping_benchmark_test.go | ||
form_mapping_test.go | ||
form_mapping.go | ||
form.go | ||
header.go | ||
json.go | ||
msgpack.go | ||
multipart_form_mapping_test.go | ||
multipart_form_mapping.go | ||
protobuf.go | ||
query.go | ||
uri.go | ||
validate_test.go | ||
xml.go | ||
yaml.go |