You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
type wrapint struct {
i int
}
func (w *wrapint) MarshalYAML() (interface{}, error) {
return w.i, nil
}
run yaml.Marshal() for
1) w := wrapint{i: 10} it will output "{}"
2) w := &wrapint{i: 10} it will output "10"
i think if it is necessary to output as "10" for both.
code:
and if you make MarshalYAML to struct:
both will output "10"
but for UnmarshalYAML,you sure need pointer as receiver in order to modify the value
The text was updated successfully, but these errors were encountered: