Quantcast
Channel: Recent Questions - Stack Overflow
Viewing all articles
Browse latest Browse all 12111

I don't want 'gopkg.in/yaml.v3' to copy my parameters. How can I implement modifying values at the source address?

$
0
0
var c struct {Name string}b := []byte(`Name: Alice`)UnmarshalYamlBytes(b, &c)
func UnmarshalYamlBytes(c []byte, v any) error {    decoder := yaml.NewDecoder(bytes.NewReader(content))    if err := decoder.Decode(&v); err != nil {        return err    }}

I tried:

func UnmarshalYamlBytes(c []byte, v any) error {    ...    ...Decode(v)...        ...    ...}it's not working

Modify the value of the parameter without changing the parameter's address

How should I do?


Viewing all articles
Browse latest Browse all 12111

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>