EncodeJSONCommon contains some common logic for the debug trace, like disabling EscapeHTML and recording error.
(input any)
| 110 | // EncodeJSONCommon contains some common logic for the debug trace, |
| 111 | // like disabling EscapeHTML and recording error. |
| 112 | func EncodeJSONCommon(input any) ([]byte, error) { |
| 113 | var buf bytes.Buffer |
| 114 | encoder := json.NewEncoder(&buf) |
| 115 | // If we do not set this to false, ">", "<", "&"... will be escaped to "\u003c","\u003e", "\u0026"... |
| 116 | encoder.SetEscapeHTML(false) |
| 117 | err := encoder.Encode(input) |
| 118 | if err != nil { |
| 119 | err = encoder.Encode(err) |
| 120 | } |
| 121 | return buf.Bytes(), err |
| 122 | } |
| 123 | |
| 124 | // EnterContextCommon records the function name of the caller, |
| 125 | // then creates and enter a new context for this debug trace structure. |
no test coverage detected
searching dependent graphs…