Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Simple quote encoded with two simple quote if ] present #444

Closed
louhde opened this issue Apr 4, 2024 · 1 comment
Closed

Simple quote encoded with two simple quote if ] present #444

louhde opened this issue Apr 4, 2024 · 1 comment
Labels
bug Something isn't working

Comments

@louhde
Copy link

louhde commented Apr 4, 2024

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
@louhde louhde added the bug Something isn't working label Apr 4, 2024
@louhde
Copy link
Author

louhde commented Apr 4, 2024

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

@louhde louhde closed this as completed Apr 4, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant