File tree 1 file changed +49
-2
lines changed
1 file changed +49
-2
lines changed Original file line number Diff line number Diff line change @@ -38,7 +38,55 @@ type Config struct {
38
38
39
39
However, sometimes this value is passed in as a literal constant, such as the paging size when querying a database. In
40
40
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
42
90
designed to solve.
43
91
44
92
# 3. Example Code
@@ -86,4 +134,3 @@ func main() {
86
134
87
135
88
136
89
-
You can’t perform that action at this time.
0 commit comments