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

fix(generate): remove a newline #1541

Merged
merged 1 commit into from Jan 8, 2023
Merged

fix(generate): remove a newline #1541

merged 1 commit into from Jan 8, 2023

Conversation

suzuki-shunsuke
Copy link
Member

@suzuki-shunsuke suzuki-shunsuke commented Jan 8, 2023

if err := afero.WriteFile(out.fs, cfgFilePath, []byte(file.String()+"\n"), stat.Mode()); err != nil {

A newline is duplicated.

https://github.com/goccy/go-yaml/blob/6cdefc42e112ac71cbe316e1eed264ea62f58e25/ast/ast.go#L570

// String all documents to text
func (f *File) String() string {
	docs := []string{}
	for _, doc := range f.Docs {
		docs = append(docs, doc.String())
	}
	if len(docs) > 0 {
		return strings.Join(docs, "\n") + "\n"
	} else {
		return ""
	}
}

⭕ 1.10.0
⭕ 1.20.0
⭕ 1.25.0
❌ 1.25.2
❌ 1.26.0
❌ 1.30.3

In v1.25.2, goccy/go-yaml was updated from v1.9.6 to v1.9.8.
v1.25.0...v1.25.2#diff-33ef32bf6c23acb95f5902d7097b7a1d5128ca061167ec0716715b0b9eeaa5f6

This bug was caused by this change. goccy/go-yaml#329 go-yaml v1.9.8

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

Successfully merging this pull request may close these issues.

None yet

1 participant