mirror of
https://github.com/goccy/go-yaml.git
synced 2025-12-08 06:09:57 +00:00
fix format with comment (#645)
This commit is contained in:
parent
0653c80843
commit
e6c495e058
2 changed files with 15 additions and 12 deletions
|
|
@ -2757,8 +2757,9 @@ type unmarshalList struct {
|
|||
|
||||
func (u *unmarshalList) UnmarshalYAML(b []byte) error {
|
||||
expected := `
|
||||
- b: c
|
||||
d: |
|
||||
- b: c # comment
|
||||
# comment
|
||||
d: | # comment
|
||||
hello
|
||||
|
||||
hello
|
||||
|
|
@ -2807,8 +2808,9 @@ config:
|
|||
func TestDecoder_UnmarshalBytesWithSeparatedList(t *testing.T) {
|
||||
yml := `
|
||||
a:
|
||||
- b: c
|
||||
d: |
|
||||
- b: c # comment
|
||||
# comment
|
||||
d: | # comment
|
||||
hello
|
||||
|
||||
hello
|
||||
|
|
@ -2818,7 +2820,8 @@ a:
|
|||
var v struct {
|
||||
A unmarshalList
|
||||
}
|
||||
if err := yaml.Unmarshal([]byte(yml), &v); err != nil {
|
||||
cm := yaml.CommentMap{}
|
||||
if err := yaml.UnmarshalWithOptions([]byte(yml), &v, yaml.CommentToMap(cm)); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if len(v.A.v) != 2 {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue