We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent bd9d715 commit 412d287Copy full SHA for 412d287
common/formatter/text.go
@@ -18,6 +18,7 @@
18
package formatter
19
20
import (
21
+ "errors"
22
"fmt"
23
"time"
24
@@ -30,7 +31,14 @@ type TextFormatter struct{}
30
31
32
// Format implements Formatter interface
33
func (tp *TextFormatter) Format(msg interface{}) (string, error) {
- return fmt.Sprintf("%s", msg), nil
34
+ if msg == nil {
35
+ return "<nil>", nil
36
+ }
37
+ str, ok := msg.(fmt.Stringer)
38
+ if !ok {
39
+ return "", errors.New("object can't be formatted as text")
40
41
+ return str.String(), nil
42
}
43
44
// DownloadProgressBar implements Formatter interface
0 commit comments