@@ -22,8 +22,9 @@ faster than other packages according to public benchmarks.
22
22
## Table of contents
23
23
24
24
* [ Installation] ( #installation )
25
- * [ API reference] ( #api-reference )
26
- * [ Walking\- through example in Go] ( #walking-through-example-in-go )
25
+ * [ Documentation] ( #documentation )
26
+ * [ API reference] ( #api-reference )
27
+ * [ Walking\- through example] ( #walking-through-example )
27
28
* [ Contributing] ( #contributing )
28
29
* [ Alternative connectors] ( #alternative-connectors )
29
30
@@ -50,7 +51,7 @@ This should put the source and binary files in subdirectories of
50
51
` github.com/tarantool/go-tarantool ` to the ` import {...} ` section at the start
51
52
of any Go program.
52
53
53
- < h2 >API reference</ h2 >
54
+ ## Documentation
54
55
55
56
Read the [ Tarantool documentation] ( tarantool-doc-data-model-url )
56
57
to find descriptions of terms such as "connect", "space", "index", and the
@@ -65,56 +66,56 @@ The supported requests have parameters and results equivalent to requests in
65
66
the [ Tarantool CRUD operations] ( tarantool-doc-box-space-url ) .
66
67
There are also Typed and Async versions of each data-manipulation function.
67
68
68
- ## Walking-through example in Go
69
+ ### API Reference
69
70
70
- We can now have a closer look at the ` example.go ` program and make some observations
71
+ Learn API documentation and examples at
72
+ [ pkg.go.dev] ( https://pkg.go.dev/github.com/tarantool/go-tarantool ) .
73
+
74
+ ### Walking-through example
75
+
76
+ We can now have a closer look at the example and make some observations
71
77
about what it does.
72
78
73
79
``` go
74
- package main
80
+ package tarantool
75
81
76
82
import (
77
- " fmt"
78
- " github.com/tarantool/go-tarantool"
83
+ " fmt"
84
+ " github.com/tarantool/go-tarantool"
79
85
)
80
86
81
87
func main () {
82
- opts := tarantool.Opts {User: " guest" }
83
- conn , err := tarantool.Connect (" 127.0.0.1:3301" , opts)
84
- // conn, err := tarantool.Connect("/path/to/tarantool.socket", opts)
85
- if err != nil {
86
- fmt.Println (" Connection refused:" , err)
87
- }
88
- resp , err := conn.Insert (999 , []interface {}{99999 , " BB" })
89
- if err != nil {
90
- fmt.Println (" Error" , err)
91
- fmt.Println (" Code" , resp.Code )
92
- }
88
+ opts := tarantool.Opts {User: " guest" }
89
+ conn , err := tarantool.Connect (" 127.0.0.1:3301" , opts)
90
+ if err != nil {
91
+ fmt.Println (" Connection refused:" , err)
92
+ }
93
+ resp , err := conn.Insert (999 , []interface {}{99999 , " BB" })
94
+ if err != nil {
95
+ fmt.Println (" Error" , err)
96
+ fmt.Println (" Code" , resp.Code )
97
+ }
93
98
}
94
99
```
95
100
96
- ** Observation 1:** the line "` github.com/tarantool/go-tarantool ` " in the
101
+ ** Observation 1:** The line "` github.com/tarantool/go-tarantool ` " in the
97
102
` import(...) ` section brings in all Tarantool-related functions and structures.
98
103
99
- ** Observation 2:** the line beginning with "` Opts := ` " sets up the options for
100
- ` Connect() ` . In this example, there is only one thing in the structure, a user
101
- name. The structure can also contain:
102
-
103
- * ` Pass ` (password),
104
- * ` Timeout ` (maximum number of milliseconds to wait before giving up),
105
- * ` Reconnect ` (number of seconds to wait before retrying if a connection fails),
106
- * ` MaxReconnect ` (maximum number of times to retry).
104
+ ** Observation 2:** The line starting with "` Opts := ` " sets up the options for
105
+ ` Connect() ` . In this example, the structure contains only a single value, the
106
+ username. The structure may also contain other settings, see more in
107
+ [ documentation] [ godoc-opts-url ] for the "` Opts ` " structure.
107
108
108
- ** Observation 3:** the line containing "` tarantool.Connect ` " is essential for
109
- beginning any session. There are two parameters:
109
+ ** Observation 3:** The line containing "` tarantool.Connect ` " is essential for
110
+ starting a session. There are two parameters:
110
111
111
112
* a string with ` host:port ` format, and
112
113
* the option structure that was set up earlier.
113
114
114
- ** Observation 4:** the ` err ` structure will be ` nil ` if there is no error,
115
+ ** Observation 4:** The ` err ` structure will be ` nil ` if there is no error,
115
116
otherwise it will have a description which can be retrieved with ` err.Error() ` .
116
117
117
- ** Observation 5:** the ` Insert ` request, like almost all requests, is preceded by
118
+ ** Observation 5:** The ` Insert ` request, like almost all requests, is preceded by
118
119
"` conn. ` " which is the name of the object that was returned by ` Connect() ` .
119
120
There are two parameters:
120
121
@@ -151,3 +152,4 @@ See feature comparison in [documentation](https://www.tarantool.io/en/doc/latest
151
152
[ go-tarantool ] : https://github.com/tarantool/go-tarantool
152
153
[ tarantool-doc-data-model-url ] : https://www.tarantool.io/en/doc/latest/book/box/data_model/
153
154
[ tarantool-doc-box-space-url ] : https://www.tarantool.io/en/doc/latest/reference/reference_lua/box_space/
155
+ [ godoc-opts-url ] : https://pkg.go.dev/github.com/tarantool/go-tarantool#Opts
0 commit comments