k0kubun/pp

Fold large buffers

Opened this issue · 1 comments

I want to print a struct contains a large buffer.

type Foo struct {
    B [65535]byte
}

func main() {
    m := Foo{}
    pp.Print(m)
}

But it's not pretty and takes a long time:

    ...
    ...
    ...
    0x0,
    0x0,
    0x0,
    0x0,
    0x0,
    0x0,
    0x0,
    0x0,
    0x0,
    0x0,
    ...
    ...
    ...

I prefer large buffers printed like this:

main.Foo{
  B: [65535]uint8{...},
}

I agree. Your example seems nice.

If we have API to change its threshold, it'll be better.

func init() {
  pp.SetBufferLimit(1028)
}