@@ -16,32 +16,21 @@ type Tuple struct {
16
16
Name string
17
17
}
18
18
19
- func example_connect () ( * tarantool.Connection , error ) {
19
+ func example_connect () * tarantool.Connection {
20
20
conn , err := tarantool .Connect (server , opts )
21
21
if err != nil {
22
- return nil , err
22
+ panic ( "Connection is not established" )
23
23
}
24
- _ , err = conn .Replace (spaceNo , []interface {}{uint (1111 ), "hello" , "world" })
25
- if err != nil {
26
- conn .Close ()
27
- return nil , err
28
- }
29
- _ , err = conn .Replace (spaceNo , []interface {}{uint (1112 ), "hallo" , "werld" })
30
- if err != nil {
31
- conn .Close ()
32
- return nil , err
33
- }
34
- return conn , nil
24
+ return conn
35
25
}
36
26
37
27
func ExampleConnection_Select () {
38
- var conn * tarantool.Connection
39
- conn , err := example_connect ()
40
- if err != nil {
41
- fmt .Printf ("error in prepare is %v" , err )
42
- return
43
- }
28
+ conn := example_connect ()
44
29
defer conn .Close ()
30
+
31
+ conn .Replace (spaceNo , []interface {}{uint (1111 ), "hello" , "world" })
32
+ conn .Replace (spaceNo , []interface {}{uint (1112 ), "hallo" , "werld" })
33
+
45
34
resp , err := conn .Select (512 , 0 , 0 , 100 , tarantool .IterEq , []interface {}{uint (1111 )})
46
35
if err != nil {
47
36
fmt .Printf ("error in select is %v" , err )
@@ -61,15 +50,10 @@ func ExampleConnection_Select() {
61
50
}
62
51
63
52
func ExampleConnection_SelectTyped () {
64
- var conn * tarantool.Connection
65
- conn , err := example_connect ()
66
- if err != nil {
67
- fmt .Printf ("error in prepare is %v" , err )
68
- return
69
- }
53
+ conn := example_connect ()
70
54
defer conn .Close ()
71
55
var res []Tuple
72
- err = conn .SelectTyped (512 , 0 , 0 , 100 , tarantool .IterEq , tarantool.IntKey {1111 }, & res )
56
+ err : = conn .SelectTyped (512 , 0 , 0 , 100 , tarantool .IterEq , tarantool.IntKey {1111 }, & res )
73
57
if err != nil {
74
58
fmt .Printf ("error in select is %v" , err )
75
59
return
@@ -87,12 +71,7 @@ func ExampleConnection_SelectTyped() {
87
71
}
88
72
89
73
func ExampleConnection_SelectAsync () {
90
- var conn * tarantool.Connection
91
- conn , err := example_connect ()
92
- if err != nil {
93
- fmt .Printf ("error in prepare is %v" , err )
94
- return
95
- }
74
+ conn := example_connect ()
96
75
defer conn .Close ()
97
76
98
77
conn .Insert (spaceNo , []interface {}{uint (16 ), "test" , "one" })
@@ -104,7 +83,7 @@ func ExampleConnection_SelectAsync() {
104
83
futs [1 ] = conn .SelectAsync ("test" , "primary" , 0 , 1 , tarantool .IterEq , tarantool.UintKey {17 })
105
84
futs [2 ] = conn .SelectAsync ("test" , "primary" , 0 , 1 , tarantool .IterEq , tarantool.UintKey {18 })
106
85
var t []Tuple
107
- err = futs [0 ].GetTyped (& t )
86
+ err : = futs [0 ].GetTyped (& t )
108
87
fmt .Println ("Future" , 0 , "Error" , err )
109
88
fmt .Println ("Future" , 0 , "Data" , t )
110
89
@@ -125,12 +104,7 @@ func ExampleConnection_SelectAsync() {
125
104
}
126
105
127
106
func ExampleConnection_Ping () {
128
- var conn * tarantool.Connection
129
- conn , err := example_connect ()
130
- if err != nil {
131
- fmt .Printf ("error in prepare is %v" , err )
132
- return
133
- }
107
+ conn := example_connect ()
134
108
defer conn .Close ()
135
109
136
110
// Ping a Tarantool instance to check connection.
@@ -145,12 +119,7 @@ func ExampleConnection_Ping() {
145
119
}
146
120
147
121
func ExampleConnection_Insert () {
148
- var conn * tarantool.Connection
149
- conn , err := example_connect ()
150
- if err != nil {
151
- fmt .Printf ("error in prepare is %v" , err )
152
- return
153
- }
122
+ conn := example_connect ()
154
123
defer conn .Close ()
155
124
156
125
// Insert a new tuple { 31, 1 }.
@@ -183,12 +152,7 @@ func ExampleConnection_Insert() {
183
152
}
184
153
185
154
func ExampleConnection_Delete () {
186
- var conn * tarantool.Connection
187
- conn , err := example_connect ()
188
- if err != nil {
189
- fmt .Printf ("error in prepare is %v" , err )
190
- return
191
- }
155
+ conn := example_connect ()
192
156
defer conn .Close ()
193
157
194
158
// Insert a new tuple { 35, 1 }.
@@ -221,12 +185,7 @@ func ExampleConnection_Delete() {
221
185
}
222
186
223
187
func ExampleConnection_Replace () {
224
- var conn * tarantool.Connection
225
- conn , err := example_connect ()
226
- if err != nil {
227
- fmt .Printf ("error in prepare is %v" , err )
228
- return
229
- }
188
+ conn := example_connect ()
230
189
defer conn .Close ()
231
190
232
191
// Insert a new tuple { 13, 1 }.
@@ -275,12 +234,7 @@ func ExampleConnection_Replace() {
275
234
}
276
235
277
236
func ExampleConnection_Update () {
278
- var conn * tarantool.Connection
279
- conn , err := example_connect ()
280
- if err != nil {
281
- fmt .Printf ("error in prepare is %v" , err )
282
- return
283
- }
237
+ conn := example_connect ()
284
238
defer conn .Close ()
285
239
286
240
// Insert a new tuple { 14, 1 }.
@@ -300,12 +254,7 @@ func ExampleConnection_Update() {
300
254
}
301
255
302
256
func ExampleConnection_Call17 () {
303
- var conn * tarantool.Connection
304
- conn , err := example_connect ()
305
- if err != nil {
306
- fmt .Printf ("error in prepare is %v" , err )
307
- return
308
- }
257
+ conn := example_connect ()
309
258
defer conn .Close ()
310
259
311
260
// Call a function 'func_name' with arguments.
@@ -322,12 +271,7 @@ func ExampleConnection_Call17() {
322
271
}
323
272
324
273
func ExampleConnection_Eval () {
325
- var conn * tarantool.Connection
326
- conn , err := example_connect ()
327
- if err != nil {
328
- fmt .Printf ("error in prepare is %v" , err )
329
- return
330
- }
274
+ conn := example_connect ()
331
275
defer conn .Close ()
332
276
333
277
// Run raw Lua code.
0 commit comments