Skip to content

Commit 3d268f1

Browse files
committed
doc: add external types imports to main examples
Closes #352
1 parent 58711e8 commit 3d268f1

File tree

2 files changed

+23
-8
lines changed

2 files changed

+23
-8
lines changed

MIGRATION.md

+6
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,9 @@ import (
5050
"fmt"
5151

5252
"github.com/tarantool/go-tarantool"
53+
_ "github.com/tarantool/go-tarantool/v2/datetime"
54+
_ "github.com/tarantool/go-tarantool/v2/decimal"
55+
_ "github.com/tarantool/go-tarantool/v2/uuid"
5356
)
5457

5558
func main() {
@@ -80,6 +83,9 @@ import (
8083
"time"
8184

8285
"github.com/tarantool/go-tarantool/v2"
86+
_ "github.com/tarantool/go-tarantool/v2/datetime"
87+
_ "github.com/tarantool/go-tarantool/v2/decimal"
88+
_ "github.com/tarantool/go-tarantool/v2/uuid"
8389
)
8490

8591
func main() {

README.md

+17-8
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ faster than other packages according to public benchmarks.
2727
* [API reference](#api-reference)
2828
* [Walking\-through example](#walking-through-example)
2929
* [Example with encrypting traffic](#example-with-encrypting-traffic)
30-
* [Migration guide](#migration-guide)
30+
* [Migration guide](#migration-guide)
3131
* [Contributing](#contributing)
3232
* [Alternative connectors](#alternative-connectors)
3333

@@ -99,6 +99,9 @@ import (
9999
"time"
100100

101101
"github.com/tarantool/go-tarantool/v2"
102+
_ "github.com/tarantool/go-tarantool/v2/datetime"
103+
_ "github.com/tarantool/go-tarantool/v2/decimal"
104+
_ "github.com/tarantool/go-tarantool/v2/uuid"
102105
)
103106

104107
func main() {
@@ -131,19 +134,22 @@ func main() {
131134
**Observation 1:** The line "`github.com/tarantool/go-tarantool/v2`" in the
132135
`import(...)` section brings in all Tarantool-related functions and structures.
133136

134-
**Observation 2:** The line starting with "`ctx, cancel :=`" creates a context
137+
**Observation 2:** Unused import lines are required to initialize encoders and
138+
decoders for external `msgpack` types.
139+
140+
**Observation 3:** The line starting with "`ctx, cancel :=`" creates a context
135141
object for `Connect()`. The `Connect()` call will return an error when a
136142
timeout expires before the connection is established.
137143

138-
**Observation 3:** The line starting with "`dialer :=`" creates dialer for
144+
**Observation 4:** The line starting with "`dialer :=`" creates dialer for
139145
`Connect()`. This structure contains fields required to establish a connection.
140146

141-
**Observation 4:** The line starting with "`opts :=`" sets up the options for
147+
**Observation 5:** The line starting with "`opts :=`" sets up the options for
142148
`Connect()`. In this example, the structure contains only a single value, the
143149
timeout. The structure may also contain other settings, see more in
144150
[documentation][godoc-opts-url] for the "`Opts`" structure.
145151

146-
**Observation 5:** The line containing "`tarantool.Connect`" is essential for
152+
**Observation 6:** The line containing "`tarantool.Connect`" is essential for
147153
starting a session. There are three parameters:
148154

149155
* a context,
@@ -155,10 +161,10 @@ There will be only one attempt to connect. If multiple attempts needed,
155161
between each try. Example could be found in the [example_test](./example_test.go),
156162
name - `ExampleConnect_reconnects`.
157163

158-
**Observation 6:** The `err` structure will be `nil` if there is no error,
164+
**Observation 7:** The `err` structure will be `nil` if there is no error,
159165
otherwise it will have a description which can be retrieved with `err.Error()`.
160166

161-
**Observation 7:** The `Insert` request, like almost all requests, is preceded
167+
**Observation 8:** The `Insert` request, like almost all requests, is preceded
162168
by the method `Do` of object `conn` which is the object that was returned
163169
by `Connect()`.
164170

@@ -179,6 +185,9 @@ import (
179185
"time"
180186

181187
"github.com/tarantool/go-tarantool/v2"
188+
_ "github.com/tarantool/go-tarantool/v2/datetime"
189+
_ "github.com/tarantool/go-tarantool/v2/decimal"
190+
_ "github.com/tarantool/go-tarantool/v2/uuid"
182191
"github.com/tarantool/go-tlsdialer"
183192
)
184193

@@ -216,7 +225,7 @@ func main() {
216225
Note that [traffic encryption](https://www.tarantool.io/en/doc/latest/enterprise/security/#encrypting-traffic)
217226
is only available in Tarantool Enterprise Edition 2.10 or newer.
218227

219-
### Migration guide
228+
## Migration guide
220229

221230
You can review the changes between major versions in the
222231
[migration guide](./MIGRATION.md).

0 commit comments

Comments
 (0)