From 1e207d561b3774f4c1c7fde50fdd7d55c8398226 Mon Sep 17 00:00:00 2001 From: Caleb Bassi Date: Thu, 24 Jan 2019 04:11:20 -0800 Subject: [PATCH] Comments --- utils.go | 3 +++ 1 file changed, 3 insertions(+) diff --git a/utils.go b/utils.go index 6b1ca75..00c389a 100644 --- a/utils.go +++ b/utils.go @@ -13,6 +13,7 @@ import ( wordwrap "github.com/mitchellh/go-wordwrap" ) +// InterfaceSlice takes an []interface{} represented as an interface{} and converts it // https://stackoverflow.com/questions/12753805/type-converting-slices-of-interfaces-in-go func InterfaceSlice(slice interface{}) []interface{} { s := reflect.ValueOf(slice) @@ -43,6 +44,7 @@ func MinInt(x, y int) int { return y } +// TrimString trims a string to a max length and adds '…' to the end if it was trimmed. func TrimString(s string, w int) string { if w <= 0 { return "" @@ -151,6 +153,7 @@ func MaxFloat64(x, y float64) float64 { return y } +// WrapCells takes []Cell and inserts Cells containing '\n' wherever a linebreak should go. func WrapCells(cells []Cell, width uint) []Cell { str := CellsToString(cells) wrapped := wordwrap.WrapString(str, width)