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

Single quoted string is not round-tripped correctly #255

Closed
martin-sucha opened this issue Oct 7, 2021 · 1 comment · Fixed by #256
Closed

Single quoted string is not round-tripped correctly #255

martin-sucha opened this issue Oct 7, 2021 · 1 comment · Fixed by #256

Comments

@martin-sucha
Copy link
Contributor

When I run this program:

package main

import (
	"os"

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

func main() {
	input := []byte(`'python script.py | grep "{''ok'': ''pong''}"'`)
	f, err := parser.ParseBytes(input, 0)
	if err != nil {
		panic(err)
	}
	_, err = os.Stdout.Write([]byte(f.String()))
	if err != nil {
		panic(err)
	}
}

It incorrectly outputs

'python script.py | grep "{'ok': 'pong'}"'

The correct, expected output is the same as the input:

'python script.py | grep "{''ok'': ''pong''}"'

Built with

require github.com/goccy/go-yaml v1.9.3
martin-sucha added a commit to kiwicom/go-yaml that referenced this issue Oct 7, 2021
According to YAML specification, single quotes must be repeated
in a single-quoted scalar.

https://yaml.org/spec/1.2.2/#732-single-quoted-style

Fixes goccy#255
@goccy
Copy link
Owner

goccy commented Oct 12, 2021

Thank you for the reporting and contribution ! I will check #256

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants