28
28
#### Latest Version
29
29
The latest stable version
30
30
``` bash
31
- go get github.com/olekukonko/
[email protected] .
6
31
+ go get github.com/olekukonko/
[email protected] .
7
32
32
```
33
33
34
34
** Warning:** Version ` v1.0.0 ` contains missing functionality and should not be used.
35
35
36
36
37
37
> ** Version Guidance**
38
- > - Production : Use ` v0.0.5 ` (stable)
38
+ > - Legacy : Use ` v0.0.5 ` (stable)
39
39
> - New Features: Use ` @latest ` (includes generics, super fast streaming APIs)
40
40
> - Legacy Docs: See [ README_LEGACY.md] ( README_LEGACY.md )
41
41
@@ -62,7 +62,7 @@ func main() {
62
62
data := [][]string {
63
63
{" Package" , " Version" , " Status" },
64
64
{" tablewriter" , " v0.0.5" , " legacy" },
65
- {" tablewriter" , " v1.0.6 " , " latest" },
65
+ {" tablewriter" , " v1.0.7 " , " latest" },
66
66
}
67
67
68
68
table := tablewriter.NewWriter (os.Stdout )
@@ -77,7 +77,7 @@ func main() {
77
77
│ PACKAGE │ VERSION │ STATUS │
78
78
├─────────────┼─────────┼────────┤
79
79
│ tablewriter │ v0.0.5 │ legacy │
80
- │ tablewriter │ v1.0.6 │ latest │
80
+ │ tablewriter │ v1.0.7 │ latest │
81
81
└─────────────┴─────────┴────────┘
82
82
```
83
83
@@ -297,7 +297,7 @@ func main() {
297
297
}
298
298
299
299
table.Configure (func (config *tablewriter.Config ) {
300
- config.Row .Formatting . Alignment = tw.AlignLeft
300
+ config.Row .Alignment . Global = tw.AlignLeft
301
301
})
302
302
table.Render ()
303
303
}
@@ -368,14 +368,12 @@ func main() {
368
368
tablewriter.WithRenderer (renderer.NewColorized (colorCfg)),
369
369
tablewriter.WithConfig (tablewriter.Config {
370
370
Row: tw.CellConfig {
371
- Formatting: tw.CellFormatting {
372
- AutoWrap: tw.WrapNormal , // Wrap long content
373
- Alignment: tw.AlignLeft , // Left-align rows
374
- },
371
+ Formatting: tw.CellFormatting {AutoWrap: tw.WrapNormal }, // Wrap long content
372
+ Alignment: tw.CellAlignment {Global: tw.AlignLeft }, // Left-align rows
375
373
ColMaxWidths: tw.CellWidth {Global: 25 },
376
374
},
377
375
Footer: tw.CellConfig {
378
- Formatting : tw.CellFormatting {Alignment : tw.AlignRight },
376
+ Alignment : tw.CellAlignment {Global : tw.AlignRight },
379
377
},
380
378
}),
381
379
)
@@ -480,19 +478,13 @@ func main() {
480
478
481
479
table := tablewriter.NewTable (os.Stdout ,
482
480
tablewriter.WithRenderer (renderer.NewBlueprint (tw.Rendition {
483
- Settings: tw.Settings {
484
- Separators: tw.Separators {BetweenRows: tw.On },
485
- },
481
+ Settings: tw.Settings {Separators: tw.Separators {BetweenRows: tw.On }},
486
482
})),
487
483
tablewriter.WithConfig (tablewriter.Config {
488
- Header: tw.CellConfig {
489
- Formatting: tw.CellFormatting {Alignment: tw.AlignCenter },
490
- },
484
+ Header: tw.CellConfig {Alignment: tw.CellAlignment {Global: tw.AlignCenter }},
491
485
Row: tw.CellConfig {
492
- Formatting: tw.CellFormatting {
493
- MergeMode: tw.MergeHierarchical ,
494
- Alignment: tw.AlignLeft ,
495
- },
486
+ Formatting: tw.CellFormatting {MergeMode: tw.MergeHierarchical },
487
+ Alignment: tw.CellAlignment {Global: tw.AlignLeft },
496
488
},
497
489
}),
498
490
)
@@ -546,21 +538,20 @@ func main() {
546
538
547
539
table := tablewriter.NewTable (os.Stdout ,
548
540
tablewriter.WithRenderer (renderer.NewBlueprint (tw.Rendition {
549
- Settings: tw.Settings {
550
- Separators: tw.Separators {BetweenRows: tw.On },
551
- },
541
+ Settings: tw.Settings {Separators: tw.Separators {BetweenRows: tw.On }},
552
542
})),
553
543
tablewriter.WithConfig (tablewriter.Config {
554
544
Row: tw.CellConfig {
555
- Formatting: tw.CellFormatting {MergeMode: tw.MergeBoth },
556
- ColumnAligns: []tw.Align {tw.Skip , tw.Skip , tw.AlignRight , tw.AlignLeft },
545
+ Formatting: tw.CellFormatting {MergeMode: tw.MergeBoth },
546
+ Alignment: tw. CellAlignment {PerColumn: []tw.Align {tw.Skip , tw.Skip , tw.AlignRight , tw.AlignLeft } },
557
547
},
548
+
558
549
Footer: tw.CellConfig {
559
550
Padding: tw.CellPadding {
560
551
Global: tw.Padding {Left: " *" , Right: " *" },
561
552
PerColumn: []tw.Padding {{}, {}, {Bottom: " ^" }, {Bottom: " ^" }},
562
553
},
563
- ColumnAligns: []tw.Align {tw.Skip , tw.Skip , tw.AlignRight , tw.AlignLeft },
554
+ Alignment: tw. CellAlignment {PerColumn: []tw.Align {tw.Skip , tw.Skip , tw.AlignRight , tw.AlignLeft } },
564
555
},
565
556
}),
566
557
)
@@ -617,9 +608,7 @@ func main() {
617
608
})),
618
609
tablewriter.WithConfig (tablewriter.Config {
619
610
MaxWidth: 10 ,
620
- Row: tw.CellConfig {
621
- Formatting: tw.CellFormatting {Alignment: tw.AlignCenter },
622
- },
611
+ Row: tw.CellConfig {Alignment: tw.CellAlignment {Global: tw.AlignCenter }},
623
612
}),
624
613
)
625
614
table.Append ([]string {s, s})
@@ -631,16 +620,12 @@ func main() {
631
620
// Main table
632
621
table := tablewriter.NewTable (os.Stdout ,
633
622
tablewriter.WithRenderer (renderer.NewBlueprint (tw.Rendition {
634
- Borders: tw.BorderNone ,
635
- Settings: tw.Settings {
636
- Separators: tw.Separators {BetweenColumns: tw.On },
637
- },
623
+ Borders: tw.BorderNone ,
624
+ Settings: tw.Settings {Separators: tw.Separators {BetweenColumns: tw.On }},
638
625
})),
639
626
tablewriter.WithConfig (tablewriter.Config {
640
627
MaxWidth: 30 ,
641
- Row: tw.CellConfig {
642
- Formatting: tw.CellFormatting {Alignment: tw.AlignCenter },
643
- },
628
+ Row: tw.CellConfig {Alignment: tw.CellAlignment {Global: tw.AlignCenter }},
644
629
}),
645
630
)
646
631
table.Append ([]string {createSubTable (" A" ), createSubTable (" B" )})
@@ -711,14 +696,11 @@ func main() {
711
696
tablewriter.WithStringer (employeeStringer),
712
697
tablewriter.WithConfig (tablewriter.Config {
713
698
Header: tw.CellConfig {
714
- Formatting: tw.CellFormatting {Alignment: tw.AlignCenter , AutoFormat: tw.On },
715
- },
716
- Row: tw.CellConfig {
717
- Formatting: tw.CellFormatting {Alignment: tw.AlignLeft },
718
- },
719
- Footer: tw.CellConfig {
720
- Formatting: tw.CellFormatting {Alignment: tw.AlignRight },
699
+ Formatting: tw.CellFormatting {AutoFormat: tw.On },
700
+ Alignment: tw.CellAlignment {Global: tw.AlignCenter },
721
701
},
702
+ Row: tw.CellConfig {Alignment: tw.CellAlignment {Global: tw.AlignLeft }},
703
+ Footer: tw.CellConfig {Alignment: tw.CellAlignment {Global: tw.AlignRight }},
722
704
}),
723
705
)
724
706
table.Header ([]string {" ID" , " Name" , " Age" , " Department" , " Salary" })
@@ -784,23 +766,17 @@ func main() {
784
766
}
785
767
786
768
table := tablewriter.NewTable (os.Stdout ,
787
- tablewriter.WithRenderer (renderer.NewHTML (os. Stdout , false , htmlCfg)),
769
+ tablewriter.WithRenderer (renderer.NewHTML (htmlCfg)),
788
770
tablewriter.WithConfig (tablewriter.Config {
789
771
Header: tw.CellConfig {
790
- Formatting: tw.CellFormatting {
791
- Alignment: tw.AlignCenter ,
792
- MergeMode: tw.MergeHorizontal , // Merge identical header cells
793
- },
772
+ Formatting: tw.CellFormatting {MergeMode: tw.MergeHorizontal }, // Merge identical header cells
773
+ Alignment: tw.CellAlignment {Global: tw.AlignCenter },
794
774
},
795
775
Row: tw.CellConfig {
796
- Formatting: tw.CellFormatting {
797
- MergeMode: tw.MergeHorizontal , // Merge identical row cells
798
- Alignment: tw.AlignLeft ,
799
- },
800
- },
801
- Footer: tw.CellConfig {
802
- Formatting: tw.CellFormatting {Alignment: tw.AlignRight },
776
+ Formatting: tw.CellFormatting {MergeMode: tw.MergeHorizontal }, // Merge identical row cells
777
+ Alignment: tw.CellAlignment {Global: tw.AlignLeft },
803
778
},
779
+ Footer: tw.CellConfig {Alignment: tw.CellAlignment {Global: tw.AlignRight }},
804
780
}),
805
781
)
806
782
0 commit comments