Format implements the NodeFormatter interface.
(ctx *FmtCtx)
| 711 | |
| 712 | // Format implements the NodeFormatter interface. |
| 713 | func (d *DInt) Format(ctx *FmtCtx) { |
| 714 | // If the number is negative, we need to use parens or the `:::INT` type hint |
| 715 | // will take precedence over the negation sign. |
| 716 | disambiguate := ctx.flags.HasFlags(fmtDisambiguateDatumTypes) |
| 717 | parsable := ctx.flags.HasFlags(FmtParsableNumerics) |
| 718 | needParens := (disambiguate || parsable) && *d < 0 |
| 719 | if needParens { |
| 720 | ctx.WriteByte('(') |
| 721 | } |
| 722 | ctx.WriteString(strconv.FormatInt(int64(*d), 10)) |
| 723 | if needParens { |
| 724 | ctx.WriteByte(')') |
| 725 | } |
| 726 | } |
| 727 | |
| 728 | // Size implements the Datum interface. |
| 729 | func (d *DInt) Size() uintptr { |