1
0
mirror of https://github.com/golang/go synced 2024-11-17 13:44:43 -07:00

context/context.go: update stringify

Is it better to use switch type?
This commit is contained in:
喜欢兰花山丘 2019-04-16 11:41:45 +08:00 committed by GitHub
parent f248cd3a07
commit 9d654de10e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -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>"