mirror of https://github.com/golang/go.git
context: simplify stringify with a type switch
Minor style change.
Change-Id: Ib30243a71a83de1a67d3d005bfdd1e04265fca1e
GitHub-Last-Rev: 9d654de10e
GitHub-Pull-Request: golang/go#31479
Reviewed-on: https://go-review.googlesource.com/c/go/+/172199
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Reviewed-by: Sameer Ajmani <sameer@golang.org>
This commit is contained in:
parent
4ee85e67e1
commit
c4953a62f9
|
|
@ -497,10 +497,10 @@ type valueCtx struct {
|
||||||
// want context depending on the unicode tables. This is only used by
|
// want context depending on the unicode tables. This is only used by
|
||||||
// *valueCtx.String().
|
// *valueCtx.String().
|
||||||
func stringify(v interface{}) string {
|
func stringify(v interface{}) string {
|
||||||
if s, ok := v.(stringer); ok {
|
switch s := v.(type) {
|
||||||
|
case stringer:
|
||||||
return s.String()
|
return s.String()
|
||||||
}
|
case string:
|
||||||
if s, ok := v.(string); ok {
|
|
||||||
return s
|
return s
|
||||||
}
|
}
|
||||||
return "<not Stringer>"
|
return "<not Stringer>"
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue