File tree Expand file tree Collapse file tree 1 file changed +49
-2
lines changed Expand file tree Collapse file tree 1 file changed +49
-2
lines changed Original file line number Diff line number Diff line change @@ -38,7 +38,55 @@ type Config struct {
3838
3939However, sometimes this value is passed in as a literal constant, such as the paging size when querying a database. In
4040this 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
4290designed to solve.
4391
4492# 3. Example Code
@@ -86,4 +134,3 @@ func main() {
86134
87135
88136
89-
You can’t perform that action at this time.
0 commit comments