@@ -125,6 +125,13 @@ var unmarshalTests = []struct {
// BUG #1133337
{"foo: ''", map[string]*string{"foo": new(string)}},
{"foo: null", map[string]string{}},
+
+ // Ignored field
+ {"a: 1\nb: 2\n",
+ &struct {
+ A int
+ B int "-"
+ }{1, 0}},
}
func (s *S) TestUnmarshal(c *C) {
@@ -104,6 +104,13 @@ var marshalTests = []struct {
u int
A int
}{0, 1}},
+ {"a: 1\n",
+ }{1, 2}},
func (s *S) TestMarshal(c *C) {
@@ -187,6 +187,9 @@ func getStructFields(st reflect.Type) (*structFields, error) {
if tag == "" && strings.Index(string(field.Tag), ":") < 0 {
tag = string(field.Tag)
+ if tag == "-" {
+ continue
+ }
// XXX Drop this after a few releases.
if s := strings.Index(tag, "/"); s >= 0 {