goprettytable

How to prevent long tables breaking up using the GoPrettyTable library in Go code?


I am learning about the Go PrettyTable library and have come across an issue while trying to print tables with long columns.

If I print a short table, it prints without any issue on the terminal screen. Example: enter image description here

But if I try to print a long table with many columns, the output breaks the table and looks like this: enter image description here

Is it possible to make the tables horizontally scrollable so that the table could be viewed without it being broken?

For reference, the code that is creating this table can be accessed from here


Solution

  • Short answer is that a 'horizontally scrollable' wide table is not possible by modifying the program code.

    Alternatively, you will have to:
    -- reduce the number of columns that are to be displayed
    -- you can reduce the terminal size to view the unbroken table
    -- save the output as pdf or other formats

    Special thanks to @Volker for helping me understand this!