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 11# Go Pointer
22
3- # 引入依赖
3+ # 一、 引入依赖
44
55``` text
66go get -u github.com/golang-infrastructure/go-pointer
77```
88
9- # 解决了什么问题
9+ # 二、 解决了什么问题
1010
1111在golang中基本类型因为没有包装类型,这就导致基本类型无法区分出nil和零值,于是所以很多库都倾向于采用基本类型变量的指针来区分是没有传递还是传递了零值。
1212
@@ -34,16 +34,16 @@ type Config struct {
3434
3535但是有时候这个值就是一个字面值常量传进去的,比如查询数据库时的分页大小等,这个时候如果要获取指针类型的话就有点麻烦,上面这个场景只是举了一个例子,这个模块就是用来解决类似的问题的。
3636
37- # Example Code
37+ # 三、 Example Code
3838
39- 目前已经支持泛型:
39+ 目前已经支持泛型:
4040
4141``` go
4242package main
4343
4444import (
4545 " fmt"
46- " github.com/CC11001100 /go-pointer "
46+ pointer " github.com/golang-infrastructure /go-reflect-utils "
4747)
4848
4949func main () {
@@ -76,7 +76,7 @@ func main() {
7676 fmt.Println (orDefault) // Output: 0
7777}
7878```
79-
79+
8080
8181
8282
Original file line number Diff line number Diff line change @@ -2,7 +2,7 @@ package main
22
33import (
44 "fmt"
5- "github.com/CC11001100 /go-pointer"
5+ "github.com/golang-infrastructure /go-pointer"
66)
77
88func 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
22
33go 1.18
44
You can’t perform that action at this time.
0 commit comments