-
-
Notifications
You must be signed in to change notification settings - Fork 41
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
Replace YAML parsers #1663
Labels
enhancement
New feature or request
Comments
How do we keep indent by yaml.v3? https://go.dev/play/p/TubU0SPmY69 package main
import (
"log"
"os"
"gopkg.in/yaml.v3"
)
func main() {
if err := core(); err != nil {
log.Fatal(err)
}
}
const data = `
---
packages:
- name: cli/[email protected]
`
func core() error {
var cfg yaml.Node
if err := yaml.Unmarshal([]byte(data), &cfg); err != nil {
return err
}
if err := yaml.NewEncoder(os.Stdout).Encode(&cfg); err != nil {
return err
}
return nil
} Result: Indent was changed. packages:
- name: cli/[email protected] I found issues. |
|
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
There are three packages.
We couldn't use gopkg.in/yaml.v3 because gopkg.in/yaml.v3 didn't have Git tags.
But currently gopkg.in/yaml.v3 has tags, so we can use gopkg.in/yaml.v3 safely.
Replace goccy/go-yaml to gopkg.in/yaml.v3 partially
We use goccy/go-yaml for the following purposes.
Regarding IndentSequence, we still use goccy/go-yaml because only goccy/go-yaml supports this feature.
But regarding patching, maybe we can use gopkg.in/yaml.v3 instead of goccy/go-yaml.
I haven't patch YAML using gopkg.in/yaml.v3, so I have to verify it.
goccy/go-yaml has some issues.
aqua g -i
ignores the indent ofregistries
whenpackages:
is empty #585aqua g -i
removes new lines #584Replace gopkg.in/yaml.v2 to gopkg.in/yaml.v3
We use gopkg.in/yaml.v2 instead of gopkg.in/yaml.v3 because gopkg.in/yaml.v3 couldn't parse YAML which has duplicated keys.
aqua should allow invalid YAML as much as possible, so we couldn't use gopkg.in/yaml.v3.
But I reconsider that we can use gopkg.in/yaml.v3 mainly and use gopkg.in/yaml.v2 only when gopkg.in/yaml.v3 can't parse YAML.
The text was updated successfully, but these errors were encountered: