MarshalIndent works like Marshal, but each XML element begins on a new indented line that starts with prefix and is followed by one or more copies of indent according to the nesting depth.
(v any, prefix, indent string)
| 128 | // indented line that starts with prefix and is followed by one or more |
| 129 | // copies of indent according to the nesting depth. |
| 130 | func MarshalIndent(v any, prefix, indent string) ([]byte, error) { |
| 131 | var b bytes.Buffer |
| 132 | enc := NewEncoder(&b) |
| 133 | enc.Indent(prefix, indent) |
| 134 | if err := enc.Encode(v); err != nil { |
| 135 | return nil, err |
| 136 | } |
| 137 | if err := enc.Close(); err != nil { |
| 138 | return nil, err |
| 139 | } |
| 140 | return b.Bytes(), nil |
| 141 | } |
| 142 | |
| 143 | // An Encoder writes XML data to an output stream. |
| 144 | type Encoder struct { |
nothing calls this directly
no test coverage detected