Simple quote encoded with two simple quote if ] present
louhde opened this issue · comments
Describe the bug
When a string contains simple quote and [ symbol, the simple quote is encoded with double single quote
To Reproduce
main.go
package main
import (
"os"
"gopkg.in/yaml.v2"
)
type Test struct {
Name string `yaml:"name"`
Test string `yaml:"test"`
}
func main() {
test := Test{
Name: "NAME",
Test: "['value', 'value2']",
}
out, err := yaml.Marshal(test)
if err != nil {
panic(err)
}
err = os.WriteFile("test.yaml", out, 0644)
if err != nil {
panic(err)
}
}
test.yaml
name: NAME
test: '[''value'', ''value2'']'
Expected behavior
test.yaml
name: NAME
test: "['value', 'value2']"
Version Variables
- Go version: go1.22.0
- go-yaml's Version: v2.4.0
I just see that there are two differents go-yaml package the official one and yours, sorry the issue does not concern your package. I close