From 3476ea062a33b87087355b80c073233f36d26f38 Mon Sep 17 00:00:00 2001 From: Oleksandr Redko Date: Thu, 12 Dec 2024 20:17:17 +0200 Subject: [PATCH] Fix displaying testable example on pkg.go.dev --- decode_test.go | 8 ++++---- encode_test.go | 8 ++++---- path_test.go | 4 ++-- 3 files changed, 10 insertions(+), 10 deletions(-) diff --git a/decode_test.go b/decode_test.go index 7d64be57..643f9aa4 100644 --- a/decode_test.go +++ b/decode_test.go @@ -1999,7 +1999,7 @@ w: w_value } } -func Example_YAMLTags() { +func ExampleUnmarshal_yAMLTags() { yml := `--- foo: 1 bar: c @@ -2179,7 +2179,7 @@ map: &map }) } -func Example_JSONTags() { +func ExampleUnmarshal_jSONTags() { yml := `--- foo: 1 bar: c @@ -2198,7 +2198,7 @@ bar: c // c } -func Example_DisallowUnknownField() { +func ExampleDecoder_Decode_disallowUnknownField() { var v struct { A string `yaml:"simple"` C string `yaml:"complicated"` @@ -2219,7 +2219,7 @@ unknown: string // ^ } -func Example_Unmarshal_Node() { +func ExampleNodeToValue() { f, err := parser.ParseBytes([]byte("text: node example"), 0) if err != nil { panic(err) diff --git a/encode_test.go b/encode_test.go index a8a3205b..b0323163 100644 --- a/encode_test.go +++ b/encode_test.go @@ -1289,7 +1289,7 @@ func TestEncoder_MultipleDocuments(t *testing.T) { } } -func Example_Marshal_Node() { +func ExampleMarshal_node() { type T struct { Text ast.Node `yaml:"text"` } @@ -1306,7 +1306,7 @@ func Example_Marshal_Node() { // text: node example } -func Example_Marshal_ExplicitAnchorAlias() { +func ExampleMarshal_explicitAnchorAlias() { type T struct { A int B string @@ -1329,7 +1329,7 @@ func Example_Marshal_ExplicitAnchorAlias() { // d: *x } -func Example_Marshal_ImplicitAnchorAlias() { +func ExampleMarshal_implicitAnchorAlias() { type T struct { I int S string @@ -1454,7 +1454,7 @@ func (t TextMarshaler) MarshalText() ([]byte, error) { return []byte(strconv.FormatInt(int64(t), 8)), nil } -func Example_MarshalYAML() { +func ExampleMarshal() { var slow SlowMarshaler slow.A = "Hello slow poke" slow.B = 100 diff --git a/path_test.go b/path_test.go index ddca8bc7..84e6cc0d 100644 --- a/path_test.go +++ b/path_test.go @@ -634,7 +634,7 @@ b: "hello" // 3 | b: "hello" } -func ExamplePath_AnnotateSourceWithComment() { +func ExamplePath_AnnotateSource_withComment() { yml := ` # This is my document doc: @@ -664,7 +664,7 @@ doc: // 9 | other: value3 } -func ExamplePath_PathString() { +func ExamplePathString() { yml := ` store: book: