🐛 Don't use encoding/json in config command

This commit is contained in:
M. Mert Yildiran 2023-09-21 21:52:43 +03:00
parent 9bc3ea5ffc
commit 65ab0ca668
No known key found for this signature in database
GPG Key ID: DA5D6DCBB758A461

View File

@ -2,28 +2,15 @@ package utils
import (
"bytes"
"encoding/json"
"github.com/goccy/go-yaml"
)
func PrettyYaml(data interface{}) (result string, err error) {
var marshalled []byte
marshalled, err = json.Marshal(data)
if err != nil {
return
}
var unmarshalled interface{}
err = json.Unmarshal(marshalled, &unmarshalled)
if err != nil {
return
}
buffer := new(bytes.Buffer)
encoder := yaml.NewEncoder(buffer, yaml.Indent(2))
err = encoder.Encode(unmarshalled)
err = encoder.Encode(data)
if err != nil {
return
}