easegress-io/easegress

[Bug]: codectool duplicate Unmarshal json

youkale opened this issue · 0 comments

Describe the bug

I found duplicate Unmarshal in the course of reading the code

branch: master
commit: b7ba81d
path : github.com/megaease/easegress/pkg/util/codectool

// Unmarshal wraps json.Unmarshal.
// It will convert yaml to json before unmarshal.
// Since json is a subset of yaml, passing json through this method should be a no-op.
func Unmarshal(data []byte, v interface{}) error {
	data, err := yamljsontool.YAMLToJSON(data)
	if err != nil {
		return fmt.Errorf("%s: convert yaml to json failed: %v", data, err)
	}
	json.Unmarshal(data, v)

	return json.Unmarshal(data, v)
}