pp
pp copied to clipboard
shorten result print for struct generated by protobuf
if an object has a type generated by protobuf, then the pp.Print() will show very very very long content on screen.
It would be better to show the user-defined fields.
Can you share an example code (ideally a repository) to reproduce your current situation, the output it currently generates, a proposed API you'd like to use, and the output it would generate?
@k0kubun
Can you share an example code (ideally a repository) to reproduce your current situation, the output it currently generates, a proposed API you'd like to use, and the output it would generate?
Sure. I found a repo in Github. https://github.com/kfelter/protobuf-example/tree/main The steps are:
- clone this repo and edit main.go
- add "github.com/k0kubun/pp" in import
- add pp.Println(events) at the end of main function.
- run
go mod tidy
andgo build
, it will generate a binaryprotobuf-example
- run
./protobuf-example
and there will be a very very long output like this:
Thanks for providing:
share an example code (ideally a repository) to reproduce your current situation, the output it currently generates
can you also provide the other part?:
a proposed API you'd like to use, and the output it would generate
As of now, only you can guess what you want, so only you can implement this feature. I can review a pull request if writing it is easier than doing the above.
Thanks for providing:
share an example code (ideally a repository) to reproduce your current situation, the output it currently generates
can you also provide the other part?:
a proposed API you'd like to use, and the output it would generate
As of now, only you can guess what you want, so only you can implement this feature. I can review a pull request if writing it is easier than doing the above.
@k0kubun I don't know how pp get each field, Could you point out which piece of code I should refer to and learn from. Than I may create a PR for it.
This is the place where pp gets each field: https://github.com/k0kubun/pp/blob/6f55b4dc4b268e1f0c695978898e5bb3f901c322/printer.go#L235-L249