Format implements the NodeFormatter interface.
(ctx *FmtCtx)
| 1578 | |
| 1579 | // Format implements the NodeFormatter interface. |
| 1580 | func (d *DBytes) Format(ctx *FmtCtx) { |
| 1581 | f := ctx.flags |
| 1582 | if f.HasFlags(fmtPgwireFormat) { |
| 1583 | ctx.WriteString(`\x`) |
| 1584 | writeAsHexString(ctx, string(*d)) |
| 1585 | } else if f.HasFlags(fmtFormatByteLiterals) { |
| 1586 | ctx.WriteByte('x') |
| 1587 | ctx.WriteByte('\'') |
| 1588 | _, _ = hex.NewEncoder(ctx).Write([]byte(*d)) |
| 1589 | ctx.WriteByte('\'') |
| 1590 | } else { |
| 1591 | withQuotes := !f.HasFlags(FmtBareStrings) |
| 1592 | if withQuotes { |
| 1593 | ctx.WriteByte('\'') |
| 1594 | } |
| 1595 | ctx.WriteString("\\x") |
| 1596 | writeAsHexString(ctx, string(*d)) |
| 1597 | if withQuotes { |
| 1598 | ctx.WriteByte('\'') |
| 1599 | } |
| 1600 | } |
| 1601 | } |
| 1602 | |
| 1603 | // Size implements the Datum interface. |
| 1604 | func (d *DBytes) Size() uintptr { |
nothing calls this directly
no test coverage detected