Skip to content

Commit 6d99ffd

Browse files
committed
Minor refactoring
1 parent 39054d5 commit 6d99ffd

File tree

1 file changed

+7
-6
lines changed

1 file changed

+7
-6
lines changed

output/tableoutput_test.go

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ import (
2020
"bytes"
2121
"fmt"
2222
"io"
23+
"strings"
2324
"testing"
2425

2526
"github.com/stretchr/testify/assert"
@@ -223,7 +224,7 @@ func TestTableOutput_Table(t *testing.T) {
223224
}
224225

225226
func getASCIITpl(title ...string) string {
226-
var out string
227+
var out strings.Builder
227228

228229
for _, t := range title {
229230
// center title
@@ -236,22 +237,22 @@ func getASCIITpl(title ...string) string {
236237

237238
centeredTitle := fmt.Sprintf("%*s", -width, fmt.Sprintf("%*s", (width+len(t)+even)/2, t))
238239

239-
out += fmt.Sprintf(asciiTpl, centeredTitle)
240+
out.WriteString(fmt.Sprintf(asciiTpl, centeredTitle))
240241
}
241242

242-
return out
243+
return out.String()
243244
}
244245

245246
func getTableTpl(title ...string) string {
246-
var out string
247+
var out strings.Builder
247248

248249
for _, t := range title {
249250
// center title
250251
width := 35
251252
centeredTitle := fmt.Sprintf("%*s", -width+1, fmt.Sprintf("%*s", (width+len(t))/2, t))
252253

253-
out += fmt.Sprintf(tableTpl, centeredTitle)
254+
out.WriteString(fmt.Sprintf(tableTpl, centeredTitle))
254255
}
255256

256-
return out
257+
return out.String()
257258
}

0 commit comments

Comments
 (0)