encoding/yaml: use idiomatic indentation (regression)
For some reason, yaml.v3 uses 4 spaces, instead of
the recommended 2, so this changed when moving to
this new package.
This change reverts it back.
Change-Id: I3cd1fc5a4fb575cce7e014cf51795488c7a5a8a1
Reviewed-on: https://cue-review.googlesource.com/c/cue/+/5686
Reviewed-by: Marcel van Lohuizen <mpvl@golang.org>
diff --git a/internal/encoding/yaml/encode.go b/internal/encoding/yaml/encode.go
index b0a247d..d9742e7 100644
--- a/internal/encoding/yaml/encode.go
+++ b/internal/encoding/yaml/encode.go
@@ -15,6 +15,7 @@
package yaml
import (
+ "bytes"
"math/big"
"strings"
@@ -45,7 +46,14 @@
if err != nil {
return nil, err
}
- return yaml.Marshal(y)
+ w := &bytes.Buffer{}
+ enc := yaml.NewEncoder(w)
+ // Use idiomatic indentation.
+ enc.SetIndent(2)
+ if err = enc.Encode(y); err != nil {
+ return nil, err
+ }
+ return w.Bytes(), nil
}
func encode(n ast.Node) (y *yaml.Node, err error) {