Commit c4953a62 authored by 喜欢兰花山丘's avatar 喜欢兰花山丘 Committed by Brad Fitzpatrick

context: simplify stringify with a type switch

Minor style change.

Change-Id: Ib30243a71a83de1a67d3d005bfdd1e04265fca1e
GitHub-Last-Rev: 9d654de10eaa6f01ece29790fb81bc41dfd61eaf
GitHub-Pull-Request: golang/go#31479
Reviewed-on: https://go-review.googlesource.com/c/go/+/172199Reviewed-by: default avatarBrad Fitzpatrick <bradfitz@golang.org>
Reviewed-by: default avatarSameer Ajmani <sameer@golang.org>
parent 4ee85e67
......@@ -497,10 +497,10 @@ type valueCtx struct {
// want context depending on the unicode tables. This is only used by
// *valueCtx.String().
func stringify(v interface{}) string {
if s, ok := v.(stringer); ok {
switch s := v.(type) {
case stringer:
return s.String()
}
if s, ok := v.(string); ok {
case string:
return s
}
return "<not Stringer>"
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment