diff -Nru golang-github-mitchellh-mapstructure-0.0~git20161006.0.a6ef2f0/debian/changelog golang-github-mitchellh-mapstructure-0.0~git20161204.0.5a0325d/debian/changelog --- golang-github-mitchellh-mapstructure-0.0~git20161006.0.a6ef2f0/debian/changelog 2016-10-15 09:12:04.000000000 +0000 +++ golang-github-mitchellh-mapstructure-0.0~git20161204.0.5a0325d/debian/changelog 2016-12-04 13:11:24.000000000 +0000 @@ -1,3 +1,11 @@ +golang-github-mitchellh-mapstructure (0.0~git20161204.0.5a0325d-1) unstable; urgency=medium + + * Team upload. + * Use debhelper v10 + * Imported Upstream version 0.0~git20161204.0.5a0325d + + -- Dr. Tobias Quathamer Sun, 04 Dec 2016 14:11:24 +0100 + golang-github-mitchellh-mapstructure (0.0~git20161006.0.a6ef2f0-1) unstable; urgency=medium [ Tim Potter ] diff -Nru golang-github-mitchellh-mapstructure-0.0~git20161006.0.a6ef2f0/debian/compat golang-github-mitchellh-mapstructure-0.0~git20161204.0.5a0325d/debian/compat --- golang-github-mitchellh-mapstructure-0.0~git20161006.0.a6ef2f0/debian/compat 2016-10-15 09:10:56.000000000 +0000 +++ golang-github-mitchellh-mapstructure-0.0~git20161204.0.5a0325d/debian/compat 2016-12-04 13:10:33.000000000 +0000 @@ -1 +1 @@ -9 +10 diff -Nru golang-github-mitchellh-mapstructure-0.0~git20161006.0.a6ef2f0/debian/control golang-github-mitchellh-mapstructure-0.0~git20161204.0.5a0325d/debian/control --- golang-github-mitchellh-mapstructure-0.0~git20161006.0.a6ef2f0/debian/control 2016-10-15 09:10:56.000000000 +0000 +++ golang-github-mitchellh-mapstructure-0.0~git20161204.0.5a0325d/debian/control 2016-12-04 13:10:41.000000000 +0000 @@ -6,7 +6,7 @@ Tianon Gravi , Anthony Fok , Tim Potter -Build-Depends: debhelper (>= 9), dh-golang, golang-any +Build-Depends: debhelper (>= 10), dh-golang, golang-any Standards-Version: 3.9.8 Homepage: https://github.com/mitchellh/mapstructure Vcs-Browser: https://anonscm.debian.org/cgit/pkg-go/packages/golang-github-mitchellh-mapstructure.git diff -Nru golang-github-mitchellh-mapstructure-0.0~git20161006.0.a6ef2f0/mapstructure.go golang-github-mitchellh-mapstructure-0.0~git20161204.0.5a0325d/mapstructure.go --- golang-github-mitchellh-mapstructure-0.0~git20161006.0.a6ef2f0/mapstructure.go 2016-10-15 09:11:31.000000000 +0000 +++ golang-github-mitchellh-mapstructure-0.0~git20161204.0.5a0325d/mapstructure.go 2016-12-04 13:10:18.000000000 +0000 @@ -1,5 +1,5 @@ // The mapstructure package exposes functionality to convert an -// abitrary map[string]interface{} into a native Go structure. +// arbitrary map[string]interface{} into a native Go structure. // // The Go structure can be arbitrarily complex, containing slices, // other structs, etc. and the decoder will properly decode nested @@ -651,14 +651,6 @@ fieldType := structType.Field(i) fieldKind := fieldType.Type.Kind() - if fieldType.Anonymous { - if fieldKind != reflect.Struct { - errors = appendErrors(errors, - fmt.Errorf("%s: unsupported type: %s", fieldType.Name, fieldKind)) - continue - } - } - // If "squash" is specified in the tag, we squash the field down. squash := false tagParts := strings.Split(fieldType.Tag.Get(d.config.TagName), ",") diff -Nru golang-github-mitchellh-mapstructure-0.0~git20161006.0.a6ef2f0/mapstructure_test.go golang-github-mitchellh-mapstructure-0.0~git20161204.0.5a0325d/mapstructure_test.go --- golang-github-mitchellh-mapstructure-0.0~git20161006.0.a6ef2f0/mapstructure_test.go 2016-10-15 09:11:31.000000000 +0000 +++ golang-github-mitchellh-mapstructure-0.0~git20161204.0.5a0325d/mapstructure_test.go 2016-12-04 13:10:18.000000000 +0000 @@ -42,6 +42,13 @@ Vunique string } +type SliceAlias []string + +type EmbeddedSlice struct { + SliceAlias `mapstructure:"slice_alias"` + Vunique string +} + type SquashOnNonStructType struct { InvalidSquashType int `mapstructure:",squash"` } @@ -271,8 +278,41 @@ var result EmbeddedPointer err := Decode(input, &result) - if err == nil { - t.Fatal("should get error") + if err != nil { + t.Fatalf("err: %s", err) + } + + expected := EmbeddedPointer{ + Basic: &Basic{ + Vstring: "innerfoo", + }, + Vunique: "bar", + } + if !reflect.DeepEqual(result, expected) { + t.Fatalf("bad: %#v", result) + } +} + +func TestDecode_EmbeddedSlice(t *testing.T) { + t.Parallel() + + input := map[string]interface{}{ + "slice_alias": []string{"foo", "bar"}, + "vunique": "bar", + } + + var result EmbeddedSlice + err := Decode(input, &result) + if err != nil { + t.Fatalf("got an err: %s", err.Error()) + } + + if !reflect.DeepEqual(result.SliceAlias, SliceAlias([]string{"foo", "bar"})) { + t.Errorf("slice value: %#v", result.SliceAlias) + } + + if result.Vunique != "bar" { + t.Errorf("vunique value should be 'bar': %#v", result.Vunique) } }