mirror of
https://github.com/golang/go.git
synced 2025-12-08 06:10:04 +00:00
reflect: document equality guarantee for Type
The only previous mention of this property was in the String() method. Since this is the only way to uniquely identify a type and we can't change this property without breaking the Go 1 guarantee, it seems better to document this property than hiding it on a method. Fixes #16348 Change-Id: I3d25f7d6e6007e3c15c2e13010869888d0181fc2 Reviewed-on: https://go-review.googlesource.com/27170 Reviewed-by: Ian Lance Taylor <iant@golang.org>
This commit is contained in:
parent
8050782cba
commit
ec75230b55
1 changed files with 6 additions and 0 deletions
|
|
@ -29,6 +29,12 @@ import (
|
|||
// Use the Kind method to find out the kind of type before
|
||||
// calling kind-specific methods. Calling a method
|
||||
// inappropriate to the kind of type causes a run-time panic.
|
||||
//
|
||||
// You can use == with reflect.Type values to check whether two types
|
||||
// are the same. If T1 and T2 are Go types, and v1 and v2 are values of
|
||||
// those types respectively, then reflect.TypeOf(v1) == reflect.TypeOf(v2)
|
||||
// if and only if both (interface{})(v2).(T1) and (interface{})(v1).(T2)
|
||||
// succeed.
|
||||
type Type interface {
|
||||
// Methods applicable to all types.
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue