Skip to content

Commit 57e9e1a

Browse files
author
yangyile
committed
把文档中的指针例子改改
1 parent 1f33e04 commit 57e9e1a

File tree

4 files changed

+17
-9
lines changed

4 files changed

+17
-9
lines changed

README.md

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -74,15 +74,19 @@ import (
7474
"github.com/yyle88/rese"
7575
)
7676

77-
func getSomething() (*int64, error) {
78-
v := int64(42)
77+
type SomeType struct {
78+
Rank int64
79+
}
80+
81+
func getSomething() (*SomeType, error) {
82+
v := &SomeType{Rank: 42}
7983
return &v, nil
8084
}
8185

8286
func main() {
8387
// Using P1 to check error and ensure non-nil pointer
8488
ptr := rese.P1(getSomething())
85-
fmt.Println(*ptr) // Outputs: 42
89+
fmt.Println(ptr.Rank) // Outputs: 42
8690
}
8791
```
8892

README.zh.md

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -65,15 +65,19 @@ import (
6565
"github.com/yyle88/rese"
6666
)
6767

68-
func getSomething() (*int64, error) {
69-
v := int64(42)
68+
type SomeType struct {
69+
Rank int64
70+
}
71+
72+
func getSomething() (*SomeType, error) {
73+
v := &SomeType{Rank: 42}
7074
return &v, nil
7175
}
7276

7377
func main() {
7478
// 使用 P1 来检查错误并确保指针非 `nil`
7579
ptr := rese.P1(getSomething())
76-
fmt.Println(*ptr) // 输出: 42
80+
fmt.Println(ptr.Rank) // 输出: 42
7781
}
7882
```
7983

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ require (
1313
github.com/pkg/errors v0.9.1 // indirect
1414
github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 // indirect
1515
github.com/yyle88/mutexmap v1.0.10 // indirect
16-
github.com/yyle88/zaplog v0.0.20 // indirect
16+
github.com/yyle88/zaplog v0.0.21 // indirect
1717
go.uber.org/multierr v1.11.0 // indirect
1818
go.uber.org/zap v1.27.0 // indirect
1919
gopkg.in/natefinch/lumberjack.v2 v2.2.1 // indirect

go.sum

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,8 @@ github.com/yyle88/must v0.0.20 h1:i+RU2v2wPEZba4MoA/2eUXYfZtSq99b5Ej5vlAkgn7Q=
1818
github.com/yyle88/must v0.0.20/go.mod h1:eh05Aksb3JGi2tzb6OBgoY37icxT0OHmBQEM1dvMaVQ=
1919
github.com/yyle88/mutexmap v1.0.10 h1:PIsx9KTdK6h1yH5NzBrPl21RrZ/XsE4IbgulMlhJzZE=
2020
github.com/yyle88/mutexmap v1.0.10/go.mod h1:QUYDuARLPlGj414kHewQ5tt8jkDxQXoai8H3C4Gg+yc=
21-
github.com/yyle88/zaplog v0.0.20 h1:ByVj51j2C9p5tWw8wbIdmdrMK5IS6VECh/U746t321E=
22-
github.com/yyle88/zaplog v0.0.20/go.mod h1:jN9/2IXYlpHOgoIyOTid1EPlUyGBWzFjr0dX9YKLkC0=
21+
github.com/yyle88/zaplog v0.0.21 h1:b3YBP7ThOofapa8CS/k//Odc/hXmaCmkc1rV4Jgj1VQ=
22+
github.com/yyle88/zaplog v0.0.21/go.mod h1:jN9/2IXYlpHOgoIyOTid1EPlUyGBWzFjr0dX9YKLkC0=
2323
go.uber.org/goleak v1.3.0 h1:2K3zAYmnTNqV73imy9J1T3WC+gmCePx2hEGkimedGto=
2424
go.uber.org/goleak v1.3.0/go.mod h1:CoHD4mav9JJNrW/WLlf7HGZPjdw8EucARQHekz1X6bE=
2525
go.uber.org/multierr v1.11.0 h1:blXXJkSxSSfBVBlC76pxqeO+LN3aDfLQo+309xJstO0=

0 commit comments

Comments
 (0)