@@ -18,7 +18,7 @@ import (
18
18
// if set) and xxx contains the type kind number:
19
19
// 0 (0001): Chan
20
20
// 1 (0011): Interface
21
- // 2 (0101): Ptr
21
+ // 2 (0101): Pointer
22
22
// 3 (0111): Slice
23
23
// 4 (1001): Array
24
24
// 5 (1011): Func
@@ -54,14 +54,17 @@ const (
54
54
UnsafePointer
55
55
Chan
56
56
Interface
57
- Ptr
57
+ Pointer
58
58
Slice
59
59
Array
60
60
Func
61
61
Map
62
62
Struct
63
63
)
64
64
65
+ // Ptr is the old name for the Pointer kind.
66
+ const Ptr = Pointer
67
+
65
68
func (k Kind ) String () string {
66
69
switch k {
67
70
case Bool :
@@ -104,7 +107,7 @@ func (k Kind) String() string {
104
107
return "chan"
105
108
case Interface :
106
109
return "interface"
107
- case Ptr :
110
+ case Pointer :
108
111
return "ptr"
109
112
case Slice :
110
113
return "slice"
@@ -252,7 +255,7 @@ type Type interface {
252
255
// Chan: ChanDir, Elem
253
256
// Func: In, NumIn, Out, NumOut, IsVariadic.
254
257
// Map: Key, Elem
255
- // Ptr : Elem
258
+ // Pointer : Elem
256
259
// Slice: Elem
257
260
// Struct: Field, FieldByIndex, FieldByName, FieldByNameFunc, NumField
258
261
@@ -280,7 +283,7 @@ type Type interface {
280
283
IsVariadic () bool
281
284
282
285
// Elem returns a type's element type.
283
- // It panics if the type's Kind is not Array, Chan, Map, Ptr , or Slice.
286
+ // It panics if the type's Kind is not Array, Chan, Map, Pointer , or Slice.
284
287
Elem () Type
285
288
286
289
// Field returns a struct type's i'th field.
@@ -350,13 +353,15 @@ func TypeOf(i interface{}) Type {
350
353
return ValueOf (i ).typecode
351
354
}
352
355
353
- func PtrTo (t Type ) Type {
354
- if t .Kind () == Ptr {
356
+ func PtrTo (t Type ) Type { return PointerTo (t ) }
357
+
358
+ func PointerTo (t Type ) Type {
359
+ if t .Kind () == Pointer {
355
360
panic ("reflect: cannot make **T type" )
356
361
}
357
362
ptrType := t .(rawType )<< 5 | 5 // 0b0101 == 5
358
363
if ptrType >> 5 != t {
359
- panic ("reflect: PtrTo type does not fit" )
364
+ panic ("reflect: PointerTo type does not fit" )
360
365
}
361
366
return ptrType
362
367
}
@@ -382,7 +387,7 @@ func (t rawType) Elem() Type {
382
387
383
388
func (t rawType ) elem () rawType {
384
389
switch t .Kind () {
385
- case Chan , Ptr , Slice :
390
+ case Chan , Pointer , Slice :
386
391
return t .stripPrefix ()
387
392
case Array :
388
393
index := t .stripPrefix ()
@@ -566,7 +571,7 @@ func (t rawType) Size() uintptr {
566
571
return 16
567
572
case String :
568
573
return unsafe .Sizeof ("" )
569
- case UnsafePointer , Chan , Map , Ptr :
574
+ case UnsafePointer , Chan , Map , Pointer :
570
575
return unsafe .Sizeof (uintptr (0 ))
571
576
case Slice :
572
577
return unsafe .Sizeof ([]int {})
@@ -615,7 +620,7 @@ func (t rawType) Align() int {
615
620
return int (unsafe .Alignof (complex128 (0 )))
616
621
case String :
617
622
return int (unsafe .Alignof ("" ))
618
- case UnsafePointer , Chan , Map , Ptr :
623
+ case UnsafePointer , Chan , Map , Pointer :
619
624
return int (unsafe .Alignof (uintptr (0 )))
620
625
case Slice :
621
626
return int (unsafe .Alignof ([]int (nil )))
@@ -681,7 +686,7 @@ func (t rawType) Comparable() bool {
681
686
return true
682
687
case Interface :
683
688
return true
684
- case Ptr :
689
+ case Pointer :
685
690
return true
686
691
case Slice :
687
692
return false
0 commit comments