-
-
Notifications
You must be signed in to change notification settings - Fork 197
Closed
Labels
Description
I find it a bit hard to describe, but the example below will hopefully clarify it. You can parse a line like - field: | # comment
(or any other block style indicator, like |-
etc), but if there is more than one space between the block style indicator and the #
sign, then there is a parsing error.
Here is a test.go
program to demonstrate:
package main
import (
"fmt"
"github.com/goccy/go-yaml"
)
func main() {
document1 := `
foo: | # comment
bar
`
document2 := `
foo: | # comment
bar
`
var s map[string]string
if err := yaml.Unmarshal([]byte(document1), &s); err != nil {
fmt.Print(err)
} else {
fmt.Print(s["foo"])
}
if err := yaml.Unmarshal([]byte(document2), &s); err != nil {
fmt.Print(err)
} else {
fmt.Print(s["foo"])
}
}
Using Go 1.23.2.
With go-yaml v1.13.6 I get:
$ go run test.go
bar
[2:6] found invalid token
> 2 | foo: | # comment
^
3 | bar
And with v1.15.2 I get
$ go run test.go
bar
[2:6] invalid header option: " "
> 2 | foo: | # comment
^
3 | bar