Removed fmt.Stringer artistry from all roouter and table structs

This commit is contained in:
Milos Gajdos
2019-07-09 16:17:18 +01:00
parent c5fb409760
commit 23cb811f60
5 changed files with 7 additions and 120 deletions

View File

@@ -1,12 +1,9 @@
package table
import (
"fmt"
"strings"
"sync"
"github.com/google/uuid"
"github.com/olekukonko/tablewriter"
)
// TableOptions specify routing table options
@@ -230,33 +227,6 @@ func (t *table) Size() int {
}
// String returns debug information
func (t *table) String() string {
t.RLock()
defer t.RUnlock()
// this will help us build routing table string
sb := &strings.Builder{}
// create nice table printing structure
table := tablewriter.NewWriter(sb)
table.SetHeader([]string{"Service", "Address", "Gateway", "Network", "Link", "Metric"})
for _, destRoute := range t.m {
for _, route := range destRoute {
strRoute := []string{
route.Service,
route.Address,
route.Gateway,
route.Network,
route.Link,
fmt.Sprintf("%d", route.Metric),
}
table.Append(strRoute)
}
}
// render table into sb
table.Render()
return sb.String()
func (t table) String() string {
return "table"
}