mirror of
https://github.com/kubeshark/kubeshark.git
synced 2025-08-27 21:02:09 +00:00
🐛 Don't use encoding/json
in config
command
This commit is contained in:
parent
9bc3ea5ffc
commit
65ab0ca668
@ -2,28 +2,15 @@ package utils
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"bytes"
|
"bytes"
|
||||||
"encoding/json"
|
|
||||||
|
|
||||||
"github.com/goccy/go-yaml"
|
"github.com/goccy/go-yaml"
|
||||||
)
|
)
|
||||||
|
|
||||||
func PrettyYaml(data interface{}) (result string, err error) {
|
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)
|
buffer := new(bytes.Buffer)
|
||||||
encoder := yaml.NewEncoder(buffer, yaml.Indent(2))
|
encoder := yaml.NewEncoder(buffer, yaml.Indent(2))
|
||||||
|
|
||||||
err = encoder.Encode(unmarshalled)
|
err = encoder.Encode(data)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user