-
-
Notifications
You must be signed in to change notification settings - Fork 203
Open
Labels
bugSomething isn't workingSomething isn't working
Description
Describe the bug
String "\n" is marshalled as ""
It seems that such corner cases needs to be handled separately/carefully
To Reproduce
https://go.dev/play/p/g2_Q0O3Grgi
package main
import (
"fmt"
"github.com/goccy/go-yaml"
)
func main() {
data := "\n"
buf, _ := yaml.Marshal(&data)
fmt.Printf("%#v\n", string(buf))
_ = yaml.Unmarshal(buf, &data)
fmt.Printf("%#v\n", data)
}Gives
"|\n\n"
""
Expected behavior
I expect it to stringify newline as newline
Version Variables
- Go version: 1.25
- go-yaml's Version: 1.15 (in my project and I guess latest 1.18 on go playground)
Additional context
Python stringifies it as "'\n\n '\n"
Also I guess "|+\n\n" will do the thing. I saw some lib that also explicitly sets indentation like |4+
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't working