]> Cypherpunks repositories - gostls13.git/commitdiff
context: simplify stringify with a type switch
author喜欢兰花山丘 <csharpwz@outlook.com>
Tue, 16 Apr 2019 15:08:32 +0000 (15:08 +0000)
committerBrad Fitzpatrick <bradfitz@golang.org>
Tue, 16 Apr 2019 15:33:18 +0000 (15:33 +0000)
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/+/172199
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Reviewed-by: Sameer Ajmani <sameer@golang.org>
src/context/context.go

index 77298f6531c7cb9cb458573fc85c537ec8815ea2..ad67d2301d15bf6e70eba525d074e7277b6c87c1 100644 (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>"