@@ -19,9 +19,7 @@ faster than other packages according to public benchmarks.
19
19
## Table of contents
20
20
21
21
* [ Installation] ( #installation )
22
- * [ Hello World] ( #hello-world )
23
- * [ API reference] ( #api-reference )
24
- * [ Walking\- through example] ( #walking-through-example )
22
+ * [ Documentation] ( #documentation )
25
23
* [ Help] ( #help )
26
24
* [ Contributing] ( #contributing )
27
25
* [ Alternative connectors] ( #alternative-connectors )
@@ -47,19 +45,9 @@ This should bring source and binary files into subdirectories of `/usr/local/go`
47
45
making it possible to access by adding ` github.com/tarantool/go-tarantool ` in
48
46
the ` import {...} ` section at the start of any Go program.
49
47
50
- < h2 >Hello World</ h2 >
48
+ ## Documentation
51
49
52
- In the "[ Connectors] ( https://www.tarantool.io/en/doc/latest/getting_started/getting_started_go/ ) "
53
- chapter of the Tarantool manual, there is an explanation of a very short (18-line)
54
- program written in Go. Follow the instructions at the start of the "Connectors"
55
- chapter carefully. Then cut and paste the example into a file named ` example.go ` ,
56
- and run it. You should see: nothing.
57
-
58
- If that is what you see, then you have successfully installed ` go-tarantool ` and
59
- successfully executed a program that manipulated the contents of a Tarantool
60
- database.
61
-
62
- <h2 >API reference</h2 >
50
+ ### API Reference
63
51
64
52
Read the [ Tarantool documentation] ( https://www.tarantool.io/en/doc/latest/book/box/data_model/ )
65
53
to find descriptions of terms like "connect", "space", "index", and the
@@ -76,31 +64,42 @@ The supported requests have parameters and results equivalent to requests in
76
64
the [ Tarantool CRUD operations] ( https://www.tarantool.io/en/doc/latest/reference/reference_lua/box_space/ ) .
77
65
There are also Typed and Async versions of each data-manipulation function.
78
66
79
- ## Walking-through example
67
+ ### Hello World example
68
+
69
+ In the "[ Connectors] ( https://www.tarantool.io/en/doc/latest/getting_started/getting_started_go/ ) "
70
+ chapter of the Tarantool manual, there is an explanation of a very short (18-line)
71
+ program written in Go. Follow the instructions at the start of the "Connectors"
72
+ chapter carefully. Then cut and paste the example into a file named ` example.go ` ,
73
+ and run it. You should see: nothing.
74
+
75
+ If that is what you see, then you have successfully installed ` go-tarantool ` and
76
+ successfully executed a program that manipulated the contents of a Tarantool
77
+ database.
78
+
79
+ ### Walking-through example
80
80
81
81
We can now have a closer look at the ` example.go ` program and make some observations
82
82
about what it does.
83
83
84
84
``` go
85
- package main
85
+ package tarantool_test
86
86
87
87
import (
88
- " fmt"
89
- " github.com/tarantool/go-tarantool"
88
+ " fmt"
89
+ " github.com/tarantool/go-tarantool"
90
90
)
91
91
92
- func main () {
93
- opts := tarantool.Opts {User: " guest" }
94
- conn , err := tarantool.Connect (" 127.0.0.1:3301" , opts)
95
- // conn, err := tarantool.Connect("/path/to/tarantool.socket", opts)
96
- if err != nil {
97
- fmt.Println (" Connection refused:" , err)
98
- }
99
- resp , err := conn.Insert (999 , []interface {}{99999 , " BB" })
100
- if err != nil {
101
- fmt.Println (" Error" , err)
102
- fmt.Println (" Code" , resp.Code )
103
- }
92
+ func Example_walkThrough () {
93
+ opts := tarantool.Opts {User: " guest" }
94
+ conn , err := tarantool.Connect (" 127.0.0.1:3301" , opts)
95
+ if err != nil {
96
+ fmt.Println (" Connection refused:" , err)
97
+ }
98
+ resp , err := conn.Insert (999 , []interface {}{99999 , " BB" })
99
+ if err != nil {
100
+ fmt.Println (" Error" , err)
101
+ fmt.Println (" Code" , resp.Code )
102
+ }
104
103
}
105
104
```
106
105
0 commit comments