MCPcopy Index your code
hub / github.com/gogf/gf / String

Method String

container/garray/garray_sorted_str.go:386–403  ·  view source on GitHub ↗

String returns current array as a string, which implements like json.Marshal does.

()

Source from the content-addressed store, hash-verified

384
385// String returns current array as a string, which implements like json.Marshal does.
386func (a *SortedStrArray) String() string {
387 if a == nil {
388 return ""
389 }
390 a.lazyInit()
391 a.mu.RLock()
392 defer a.mu.RUnlock()
393 buffer := bytes.NewBuffer(nil)
394 buffer.WriteByte('[')
395 for k, v := range a.array {
396 buffer.WriteString(`"` + gstr.QuoteMeta(v, `"\`) + `"`)
397 if k != len(a.array)-1 {
398 buffer.WriteByte(',')
399 }
400 }
401 buffer.WriteByte(']')
402 return buffer.String()
403}
404
405// MarshalJSON implements the interface MarshalJSON for json.Marshal.
406// Note that do not use pointer as its receiver here.

Callers

nothing calls this directly

Calls 6

lazyInitMethod · 0.95
QuoteMetaFunction · 0.92
WriteStringMethod · 0.80
StringMethod · 0.65
RLockMethod · 0.45
RUnlockMethod · 0.45

Tested by

no test coverage detected