From 6a3a8ae61bdb066ada6a0d270d8642c468149777 Mon Sep 17 00:00:00 2001 From: Andrey Nering Date: Wed, 3 May 2017 22:22:00 -0300 Subject: [PATCH] Fix time.Time binding (#904) If a empty string is given(`""`), them time should be zero. --- binding/form_mapping.go | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/binding/form_mapping.go b/binding/form_mapping.go index bc9e44c..1af8165 100644 --- a/binding/form_mapping.go +++ b/binding/form_mapping.go @@ -152,6 +152,11 @@ func setTimeField(val string, structField reflect.StructField, value reflect.Val if timeFormat == "" { return errors.New("Blank time format") } + + if val == "" { + value.Set(reflect.ValueOf(time.Time{})) + return nil + } l := time.Local if isUTC, _ := strconv.ParseBool(structField.Tag.Get("time_utc")); isUTC {