Marshal returns the XML encoding of v. Marshal handles an array or slice by marshaling each of the elements. Marshal handles a pointer by marshaling the value it points at or, if the pointer is nil, by writing nothing. Marshal handles an interface value by marshaling the value it contains or, if th
(v any)
| 78 | // |
| 79 | // Marshal will return an error if asked to marshal a channel, function, or map. |
| 80 | func Marshal(v any) ([]byte, error) { |
| 81 | var b bytes.Buffer |
| 82 | enc := NewEncoder(&b) |
| 83 | if err := enc.Encode(v); err != nil { |
| 84 | return nil, err |
| 85 | } |
| 86 | if err := enc.Close(); err != nil { |
| 87 | return nil, err |
| 88 | } |
| 89 | return b.Bytes(), nil |
| 90 | } |
| 91 | |
| 92 | // Marshaler is the interface implemented by objects that can marshal |
| 93 | // themselves into valid XML elements. |
nothing calls this directly
no test coverage detected