Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion pkg/lib/strings/operations.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ package strings

import (
"strings"
"unicode"

"github.com/cortexlabs/cortex/pkg/lib/cast"
)
Expand Down Expand Up @@ -53,10 +54,14 @@ func EnsureBlankLineIfNotEmpty(str string) string {
return str + "\n\n"
}

func RemoveTrailingNewLines(str string) string {
func TrimTrailingNewLines(str string) string {
return strings.TrimRight(str, "\n")
}

func TrimTrailingWhitespace(str string) string {
return strings.TrimRightFunc(str, unicode.IsSpace)
}

func EnsureSingleTrailingNewLine(str string) string {
return strings.TrimRight(str, "\n") + "\n"
}
Expand Down
3 changes: 2 additions & 1 deletion pkg/lib/table/table.go
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,7 @@ func (t *Table) Format(opts ...*Opts) (string, error) {
headerStr += strings.Repeat(" ", maxColWidths[colNum]+t.Spacing-len(header.Title))
}
}
headerStr = s.TrimTrailingWhitespace(headerStr)

ellipses := "..."
rowStrs := make([]string, len(rows))
Expand All @@ -185,7 +186,7 @@ func (t *Table) Format(opts ...*Opts) (string, error) {
rowStr += strings.Repeat(" ", maxColWidths[colNum]+t.Spacing-len(val))
}
}
rowStrs[rowNum] = rowStr
rowStrs[rowNum] = s.TrimTrailingWhitespace(rowStr)
}

if *mergedOpts.Sort {
Expand Down