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

Marshaler incorrectly marshals date strings #1054

Open
467892746 opened this issue Oct 17, 2024 · 0 comments
Open

Marshaler incorrectly marshals date strings #1054

467892746 opened this issue Oct 17, 2024 · 0 comments

Comments

@467892746
Copy link

The marshaler should quote strings that have YAML's date format. For example, the go string "2024-09-19T01:52:55.944" should be marshaled as '2024-09-19T01:52:55.944', with the quotes, but is currently marshaled without quotes.

SSCCE:

package main

import (
	"fmt"
	"gopkg.in/yaml.v3"
)

func main() {
	m := make(map[string]string)
	m["foo"] = "2024-09-19T01:52:55.944"
	out, _ := yaml.Marshal(m)
	fmt.Println(string(out))
}

Should output:

foo: '2024-09-19T01:52:55.944'

But instead outputs

foo: 2024-09-19T01:52:55.944

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

No branches or pull requests

1 participant