File tree Expand file tree Collapse file tree 3 files changed +8
-8
lines changed Expand file tree Collapse file tree 3 files changed +8
-8
lines changed Original file line number Diff line number Diff line change 1
1
# Go Pointer
2
2
3
- # 引入依赖
3
+ # 一、 引入依赖
4
4
5
5
``` text
6
6
go get -u github.com/golang-infrastructure/go-pointer
7
7
```
8
8
9
- # 解决了什么问题
9
+ # 二、 解决了什么问题
10
10
11
11
在golang中基本类型因为没有包装类型,这就导致基本类型无法区分出nil和零值,于是所以很多库都倾向于采用基本类型变量的指针来区分是没有传递还是传递了零值。
12
12
@@ -34,16 +34,16 @@ type Config struct {
34
34
35
35
但是有时候这个值就是一个字面值常量传进去的,比如查询数据库时的分页大小等,这个时候如果要获取指针类型的话就有点麻烦,上面这个场景只是举了一个例子,这个模块就是用来解决类似的问题的。
36
36
37
- # Example Code
37
+ # 三、 Example Code
38
38
39
- 目前已经支持泛型:
39
+ 目前已经支持泛型:
40
40
41
41
``` go
42
42
package main
43
43
44
44
import (
45
45
" fmt"
46
- " github.com/CC11001100 /go-pointer "
46
+ pointer " github.com/golang-infrastructure /go-reflect-utils "
47
47
)
48
48
49
49
func main () {
@@ -76,7 +76,7 @@ func main() {
76
76
fmt.Println (orDefault) // Output: 0
77
77
}
78
78
```
79
-
79
+
80
80
81
81
82
82
Original file line number Diff line number Diff line change @@ -2,7 +2,7 @@ package main
2
2
3
3
import (
4
4
"fmt"
5
- "github.com/CC11001100 /go-pointer"
5
+ "github.com/golang-infrastructure /go-pointer"
6
6
)
7
7
8
8
func main () {
Original file line number Diff line number Diff line change 1
- module github.com/CC11001100 /go-pointer
1
+ module github.com/golang-infrastructure /go-pointer
2
2
3
3
go 1.18
4
4
You can’t perform that action at this time.
0 commit comments