MCPcopy
hub / github.com/gogf/gf / String

Method String

container/garray/garray_normal_str.go:443–462  ·  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

441
442// String returns current array as a string, which implements like json.Marshal does.
443func (a *StrArray) String() string {
444 if a == nil {
445 return ""
446 }
447
448 a.lazyInit()
449
450 a.mu.RLock()
451 defer a.mu.RUnlock()
452 buffer := bytes.NewBuffer(nil)
453 buffer.WriteByte('[')
454 for k, v := range a.array {
455 buffer.WriteString(`"` + gstr.QuoteMeta(v, `"\`) + `"`)
456 if k != len(a.array)-1 {
457 buffer.WriteByte(',')
458 }
459 }
460 buffer.WriteByte(']')
461 return buffer.String()
462}
463
464// MarshalJSON implements the interface MarshalJSON for json.Marshal.
465// 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