diff options
| author | 喜欢兰花山丘 <csharpwz@outlook.com> | 2019-04-16 15:08:32 +0000 |
|---|---|---|
| committer | Brad Fitzpatrick <bradfitz@golang.org> | 2019-04-16 15:33:18 +0000 |
| commit | c4953a62f90f90f1ab2ac07d5664dd515936835e (patch) | |
| tree | 35d40581940c6e33238bfd7ae04752696b8a10df /src/context | |
| parent | 4ee85e67e127b6679d461f1d4ae836afdf4251f4 (diff) | |
| download | go-c4953a62f90f90f1ab2ac07d5664dd515936835e.tar.xz | |
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/+/172199
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Reviewed-by: Sameer Ajmani <sameer@golang.org>
Diffstat (limited to 'src/context')
| -rw-r--r-- | src/context/context.go | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/src/context/context.go b/src/context/context.go index 77298f6531..ad67d2301d 100644 --- a/src/context/context.go +++ b/src/context/context.go @@ -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>" |
