struct: map slices in strict mode too (#119)
Peter Vaczi authored 6 years ago
无闻 committed 6 years ago
112 | 112 |
default:
|
113 | 113 |
return fmt.Errorf("unsupported type '[]%s'", sliceOf)
|
114 | 114 |
}
|
115 | |
if isStrict {
|
116 | |
return err
|
|
115 |
if err != nil {
|
|
116 |
return wrapStrictError(err, isStrict)
|
117 | 117 |
}
|
118 | 118 |
|
119 | 119 |
slice := reflect.MakeSlice(field.Type(), numVals, numVals)
|
241 | 241 |
s := new(Strict)
|
242 | 242 |
|
243 | 243 |
So(cfg.Section("").StrictMapTo(s), ShouldNotBeNil)
|
|
244 |
})
|
|
245 |
|
|
246 |
Convey("Map slice in strict mode", t, func() {
|
|
247 |
cfg, err := Load([]byte(`
|
|
248 |
names=alice, bruce`))
|
|
249 |
So(err, ShouldBeNil)
|
|
250 |
|
|
251 |
type Strict struct {
|
|
252 |
Names []string `ini:"names"`
|
|
253 |
}
|
|
254 |
s := new(Strict)
|
|
255 |
|
|
256 |
So(cfg.Section("").StrictMapTo(s), ShouldBeNil)
|
|
257 |
So(fmt.Sprint(s.Names), ShouldEqual, "[alice bruce]")
|
244 | 258 |
})
|
245 | 259 |
|
246 | 260 |
Convey("Reflect from struct", t, func() {
|