MCPcopy Index your code
hub / github.com/lib/pq / Value

Method Value

array.go:667–688  ·  view source on GitHub ↗

Value implements the driver.Valuer interface.

()

Source from the content-addressed store, hash-verified

665
666// Value implements the driver.Valuer interface.
667func (a StringArray) Value() (driver.Value, error) {
668 if a == nil {
669 return nil, nil
670 }
671
672 if n := len(a); n > 0 {
673 // There will be at least two curly brackets, 2*N bytes of quotes,
674 // and N-1 bytes of delimiters.
675 b := make([]byte, 1, 1+3*n)
676 b[0] = '{'
677
678 b = appendArrayQuotedBytes(b, []byte(a[0]))
679 for i := 1; i < n; i++ {
680 b = append(b, ',')
681 b = appendArrayQuotedBytes(b, []byte(a[i]))
682 }
683
684 return string(append(b, '}')), nil
685 }
686
687 return "{}", nil
688}
689
690// appendArray appends rv to the buffer, returning the extended buffer and the
691// delimiter used between elements.

Callers

nothing calls this directly

Calls 1

appendArrayQuotedBytesFunction · 0.85

Tested by

no test coverage detected