Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions struct.go
Original file line number Diff line number Diff line change
Expand Up @@ -564,6 +564,10 @@ func (s *Section) reflectFrom(val reflect.Value) error {
typ := val.Type()

for i := 0; i < typ.NumField(); i++ {
if !val.Field(i).CanInterface() {
continue
}

field := val.Field(i)
tpField := typ.Field(i)

Expand Down
4 changes: 2 additions & 2 deletions struct_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -260,7 +260,6 @@ func Test_MapToStruct(t *testing.T) {
So(ts.TimePtrNil, ShouldEqual, nil)
So(*ts.DurationPtr, ShouldEqual, 0)
So(ts.DurationPtrNil, ShouldEqual, nil)

})

Convey("Map section to struct", func() {
Expand Down Expand Up @@ -440,12 +439,13 @@ func Test_ReflectFromStruct(t *testing.T) {
GPA float64
Date time.Time
NeverMind string `ini:"-"`
ignored string
*Embeded `ini:"infos" comment:"Embeded section"`
}

t, err := time.Parse(time.RFC3339, "1993-10-07T20:17:05Z")
So(err, ShouldBeNil)
a := &Author{"Unknwon", true, nil, 21, 100, 2.8, t, "",
a := &Author{"Unknwon", true, nil, 21, 100, 2.8, t, "", "ignored",
&Embeded{
[]time.Time{t, t},
[]string{"HangZhou", "Boston"},
Expand Down