Skip to content

Commit 762ce96

Browse files
joeybloggsjoeybloggs
authored andcommitted
correct native time parsing missing set = true directive
1 parent efc89b7 commit 762ce96

File tree

3 files changed

+10
-1
lines changed

3 files changed

+10
-1
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
Package form
22
============
33
<img align="right" src="https://raw.githubusercontent.com/go-playground/form/master/logo.jpg">
4-
![Project status](https://img.shields.io/badge/version-1.7.0-green.svg)
4+
![Project status](https://img.shields.io/badge/version-1.7.1-green.svg)
55
[![Build Status](https://semaphoreci.com/api/v1/joeybloggs/form/branches/master/badge.svg)](https://semaphoreci.com/joeybloggs/form)
66
[![Coverage Status](https://coveralls.io/repos/github/go-playground/form/badge.svg?branch=master)](https://coveralls.io/github/go-playground/form?branch=master)
77
[![Go Report Card](https://goreportcard.com/badge/github.com/go-playground/form)](https://goreportcard.com/report/github.com/go-playground/form)

decoder.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -554,6 +554,7 @@ func (d *decoder) setFieldByType(current reflect.Value, namespace string, idx in
554554
}
555555

556556
v.Set(reflect.ValueOf(t))
557+
set = true
557558
return
558559
}
559560

decoder_test.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ package form
22

33
import (
44
"errors"
5+
"fmt"
56
"net/url"
67
"testing"
78
"time"
@@ -654,22 +655,29 @@ func TestDecoderNativeTime(t *testing.T) {
654655
type TestError struct {
655656
Time time.Time
656657
TimeNoValue time.Time
658+
TimePtr *time.Time
657659
}
658660

659661
values := url.Values{
660662
"Time": []string{"2006-01-02T15:04:05Z"},
661663
"TimeNoValue": []string{""},
664+
"TimePtr": []string{"2006-01-02T15:04:05Z"},
662665
}
663666

664667
var test TestError
665668

666669
decoder := NewDecoder()
670+
671+
fmt.Println("decoding")
667672
errs := decoder.Decode(&test, values)
668673
Equal(t, errs, nil)
669674

670675
tm, _ := time.Parse(time.RFC3339, "2006-01-02T15:04:05Z")
671676
Equal(t, test.Time.Equal(tm), true)
672677
Equal(t, test.TimeNoValue.Equal(tm), false)
678+
679+
NotEqual(t, test.TimePtr, nil)
680+
Equal(t, (*test.TimePtr).Equal(tm), true)
673681
}
674682

675683
func TestDecoderErrors(t *testing.T) {

0 commit comments

Comments
 (0)