goccy / go-yaml

YAML support for the Go language

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Block with indent indicator is not parsed correctly

martin-sucha opened this issue · comments

Describe the bug
Yaml with block indent indicator is not parsed corrrectly, the spaces at the beginning are trimmed.

To Reproduce

package main

import (
	"os"

	"github.com/goccy/go-yaml/parser"
)

func main() {
	input, err := os.ReadFile("input6.yaml")
	if err != nil {
		panic(err)
	}
	f, err := parser.ParseBytes(input, 0)
	if err != nil {
		panic(err)
	}
	_, err = os.Stdout.Write([]byte(f.String()))
	if err != nil {
		panic(err)
	}
}
|2-

                  text

Expected behavior

Expected to get the same output as input, but got:

2-
text

The yaml should be equivalent to

"\n                text"

Version Variables

  • Go version: go1.21.1
  • go-yaml's Version: v1.11.2

Additional context
Add any other context about the problem here.