Support "-" tag.
diff --git a/decode_test.go b/decode_test.go
index 5e5663b..83532f4 100644
--- a/decode_test.go
+++ b/decode_test.go
@@ -125,6 +125,13 @@
// 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) {
diff --git a/encode_test.go b/encode_test.go
index f6a0d0f..1d63c02 100644
--- a/encode_test.go
+++ b/encode_test.go
@@ -104,6 +104,13 @@
u int
A int
}{0, 1}},
+
+ // Ignored field
+ {"a: 1\n",
+ &struct {
+ A int
+ B int "-"
+ }{1, 2}},
}
func (s *S) TestMarshal(c *C) {
diff --git a/goyaml.go b/goyaml.go
index fa288c9..eb2a29f 100644
--- a/goyaml.go
+++ b/goyaml.go
@@ -187,6 +187,9 @@
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 {