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

Method optInstrStringer

structencoder.go:162–185  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

160}
161
162func (e *StructEncoder) optInstrStringer() {
163 e.chunk(`"`)
164
165 t := reflect.ValueOf(e.t).Field(e.i).Type()
166 if e.f.Type.Kind() == reflect.Ptr {
167 t = t.Elem()
168 }
169
170 conv := func(v unsafe.Pointer, w *Buffer) {
171 e, ok := reflect.NewAt(t, v).Interface().(fmt.Stringer)
172 if !ok {
173 return
174 }
175 w.WriteString(e.String())
176 }
177
178 if e.f.Type.Kind() == reflect.Ptr {
179 e.ptrval(conv)
180 } else {
181 e.val(conv)
182 }
183
184 e.chunk(`"`)
185}
186
187func (e *StructEncoder) optInstrEncoder() {
188 t := reflect.ValueOf(e.t).Field(e.i).Type()

Callers 1

NewStructEncoderFunction · 0.95

Calls 5

chunkMethod · 0.95
ptrvalMethod · 0.95
valMethod · 0.95
WriteStringMethod · 0.80
StringMethod · 0.80

Tested by

no test coverage detected