MCPcopy Create free account
hub / github.com/XmirrorSecurity/OpenSCA-cli / MarshalIndent

Function MarshalIndent

opensca/sca/java/xml/marshal.go:130–141  ·  view source on GitHub ↗

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)

Source from the content-addressed store, hash-verified

128// indented line that starts with prefix and is followed by one or more
129// copies of indent according to the nesting depth.
130func 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.
144type Encoder struct {

Callers

nothing calls this directly

Calls 4

IndentMethod · 0.95
EncodeMethod · 0.95
CloseMethod · 0.95
NewEncoderFunction · 0.85

Tested by

no test coverage detected