Codebase list golang-github-go-ini-ini / 476f0ee
struct: map slices in strict mode too (#119) Peter Vaczi authored 6 years ago 无闻 committed 6 years ago
2 changed file(s) with 16 addition(s) and 2 deletion(s). Raw diff Collapse all Expand all
112112 default:
113113 return fmt.Errorf("unsupported type '[]%s'", sliceOf)
114114 }
115 if isStrict {
116 return err
115 if err != nil {
116 return wrapStrictError(err, isStrict)
117117 }
118118
119119 slice := reflect.MakeSlice(field.Type(), numVals, numVals)
241241 s := new(Strict)
242242
243243 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]")
244258 })
245259
246260 Convey("Reflect from struct", t, func() {