Skip to content

Commit 65a341d

Browse files
author
lixiaohui
committed
[ptr] new package to return pointer of primitive type easily
1 parent 2161c96 commit 65a341d

File tree

1 file changed

+52
-0
lines changed

1 file changed

+52
-0
lines changed

ptr/ptr.go

+52
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
package ptr
2+
3+
// Bool returns bool pointer that point to v.
4+
func Bool(v bool) *bool { return &v }
5+
6+
// String returns string pointer that point to v.
7+
func String(v string) *string { return &v }
8+
9+
// Int8 returns int8 pointer that point to v.
10+
func Int8(v int8) *int8 { return &v }
11+
12+
// Int16 returns int16 pointer that point to v.
13+
func Int16(v int16) *int16 { return &v }
14+
15+
// Int32 returns int32 pointer that point to v.
16+
func Int32(v int32) *int32 { return &v }
17+
18+
// Int64 returns int64 pointer that point to v.
19+
func Int64(v int64) *int64 { return &v }
20+
21+
// Int returns int pointer that point to v.
22+
func Int(v int) *int { return &v }
23+
24+
// Uint8 returns uint8 pointer that point to v.
25+
func Uint8(v uint8) *uint8 { return &v }
26+
27+
// Uint16 returns uint16 pointer that point to v.
28+
func Uint16(v uint16) *uint16 { return &v }
29+
30+
// Uint32 returns uint32 pointer that point to v.
31+
func Uint32(v uint32) *uint32 { return &v }
32+
33+
// Uint64 returns uint64 pointer that point to v.
34+
func Uint64(v uint64) *uint64 { return &v }
35+
36+
// Uint returns uint pointer that point to v.
37+
func Uint(v uint) *uint { return &v }
38+
39+
// Float32 returns float32 pointer that point to v.
40+
func Float32(v float32) *float32 { return &v }
41+
42+
// Float64 returns float64 pointer that point to v.
43+
func Float64(v float64) *float64 { return &v }
44+
45+
// Complex64 returns complex64 pointer that point to v.
46+
func Complex64(v complex64) *complex64 { return &v }
47+
48+
// Complex128 returns complex128 pointer that point to v.
49+
func Complex128(v complex128) *complex128 { return &v }
50+
51+
// Uintptr returns uintptr pointer that point to v.
52+
func Uintptr(v uintptr) *uintptr { return &v }

0 commit comments

Comments
 (0)