MCPcopy
hub / github.com/jackc/pgx / decodeHexBytea

Function decodeHexBytea

pgtype/bytea.go:221–237  ·  view source on GitHub ↗
(src []byte)

Source from the content-addressed store, hash-verified

219}
220
221func decodeHexBytea(src []byte) ([]byte, error) {
222 if src == nil {
223 return nil, nil
224 }
225
226 if len(src) < 2 || src[0] != '\\' || src[1] != 'x' {
227 return nil, fmt.Errorf("invalid hex format")
228 }
229
230 buf := make([]byte, (len(src)-2)/2)
231 _, err := hex.Decode(buf, src[2:])
232 if err != nil {
233 return nil, err
234 }
235
236 return buf, nil
237}
238
239func (c ByteaCodec) DecodeDatabaseSQLValue(m *Map, oid uint32, format int16, src []byte) (driver.Value, error) {
240 return c.DecodeValue(m, oid, format, src)

Callers 2

ScanMethod · 0.85
ScanMethod · 0.85

Calls 1

DecodeMethod · 0.65

Tested by

no test coverage detected