Skip to content

Commit

Permalink
Refactor switch
Browse files Browse the repository at this point in the history
  • Loading branch information
Alexander Do committed Dec 26, 2014
1 parent 121aa86 commit 07b8a81
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions formatter.go
Original file line number Diff line number Diff line change
Expand Up @@ -169,12 +169,12 @@ func (p *printer) printValue(v reflect.Value, showType, quote bool) {
writeByte(p, '{')
printed := false
if v.CanInterface() {
switch v.Interface().(type) {
switch vv := v.Interface().(type) {
case fmt.Stringer:
p.fmtString(v.Interface().(fmt.Stringer).String(), true)
p.fmtString(vv.String(), true)
printed = true
case encoding.TextMarshaler:
if b, err := v.Interface().(encoding.TextMarshaler).MarshalText(); err == nil {
if b, err := vv.MarshalText(); err == nil {
p.fmtString(string(b), true)
printed = true
}
Expand Down

1 comment on commit 07b8a81

@cee-dub
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's what I meant. Thanks!

Please sign in to comment.