MCPcopy Create free account
hub / github.com/bet365/jingo / optInstrEscape

Method optInstrEscape

structencoder.go:248–269  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

246}
247
248func (e *StructEncoder) optInstrEscape() {
249 if e.f.Type.Kind() == reflect.Slice {
250 e.flunk()
251
252 /// create an escape string encoder internally instead of mirroring the struct, so people only need to pass the ,escape opt instead
253 enc := NewSliceEncoder([]EscapeString{})
254 f := e.f
255 e.appendInstructionFun(func(v unsafe.Pointer, w *Buffer) {
256 var em interface{} = unsafe.Pointer(uintptr(v) + f.Offset)
257 enc.Marshal(em, w)
258 })
259 return
260 }
261
262 if e.f.Type.Kind() == reflect.Ptr {
263 e.ptrstringval(ptrEscapeStringToBuf)
264 } else {
265 e.chunk(`"`)
266 e.val(ptrEscapeStringToBuf)
267 e.chunk(`"`)
268 }
269}
270
271// chunk writes a chunk of body data to the chunk buffer. only for writing static
272//

Callers 1

NewStructEncoderFunction · 0.95

Calls 7

flunkMethod · 0.95
appendInstructionFunMethod · 0.95
MarshalMethod · 0.95
ptrstringvalMethod · 0.95
chunkMethod · 0.95
valMethod · 0.95
NewSliceEncoderFunction · 0.85

Tested by

no test coverage detected