Skip to content

Commit 7778f57

Browse files
committed
update
1 parent 8319cf4 commit 7778f57

File tree

1 file changed

+49
-2
lines changed

1 file changed

+49
-2
lines changed

README_en.md

+49-2
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,55 @@ type Config struct {
3838

3939
However, sometimes this value is passed in as a literal constant, such as the paging size when querying a database. In
4040
this case,
41-
getting a pointer type can be a bit of a hassle. The above scenario is just an example of a problem that this module is
41+
getting a pointer type can be a bit of a hassle:
42+
43+
```go
44+
package main
45+
46+
func main() {
47+
48+
foo := 10
49+
config := &Config{
50+
Foo: &foo,
51+
}
52+
callSomeFunction(config)
53+
54+
}
55+
```
56+
57+
If using this library:
58+
59+
```go
60+
package main
61+
62+
func main() {
63+
64+
config := &Config{
65+
Foo: pointer.ToPointer(10)
66+
}
67+
callSomeFunction(config)
68+
69+
}
70+
```
71+
72+
Diff:
73+
74+
```diff
75+
package main
76+
77+
func main() {
78+
79+
- foo := 10
80+
config := &Config{
81+
- Foo: &foo,
82+
+ Foo: pointer.ToPointer(10)
83+
}
84+
callSomeFunction(config)
85+
86+
}
87+
```
88+
89+
The above scenario is just an example of a problem that this module is
4290
designed to solve.
4391

4492
# 3. Example Code
@@ -86,4 +134,3 @@ func main() {
86134

87135

88136

89-

0 commit comments

Comments
 (0)