Skip to content

Commit 82069ae

Browse files
sanialescmaglie
authored andcommitted
fixing json formatter
1 parent adc2b15 commit 82069ae

File tree

2 files changed

+2
-2
lines changed

2 files changed

+2
-2
lines changed

Diff for: cmd/formatter/examples_test.go

-1
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,6 @@ func ExampleJSONFormatter_Print_debug() {
129129
jf.Print(newValue)
130130
// Output:
131131
// {"value":20}
132-
//
133132
// {"value":20}
134133
// Only structs and maps values are accepted
135134
// {"value2":10}

Diff for: cmd/formatter/json.go

+2-1
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ package formatter
3232
import "encoding/json"
3333
import "reflect"
3434
import "errors"
35+
import "fmt"
3536

3637
//JSONFormatter represents a Printer and Formatter of JSON objects.
3738
type JSONFormatter struct {
@@ -48,7 +49,7 @@ func (jf JSONFormatter) Format(msg interface{}) (string, error) {
4849
ret, err := json.Marshal(msg)
4950
return string(ret), err
5051
} else if jf.Debug {
51-
return "", errors.New("Only structs and maps values are accepted")
52+
return fmt.Sprint(msg), errors.New("Only structs and maps values are accepted")
5253
}
5354
return "", nil
5455
}

0 commit comments

Comments
 (0)