Skip to content

Commit 253cb27

Browse files
committed
readme: merge documentation sections into single one
- add a section 'Documentation' and two subsections: - with 'Walking Through' example - with API documentation - fix code formatting in 'Walking-Through' example - remove description of Opts settings in description for 'Walking-Through' example - remove a program name in description for 'Walking-Through' example - update English grammar in description for 'Walking Through' example Part of #123
1 parent d206a85 commit 253cb27

File tree

1 file changed

+34
-32
lines changed

1 file changed

+34
-32
lines changed

README.md

Lines changed: 34 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,9 @@ faster than other packages according to public benchmarks.
2222
## Table of contents
2323

2424
* [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)
2728
* [Contributing](#contributing)
2829
* [Alternative connectors](#alternative-connectors)
2930

@@ -50,7 +51,7 @@ This should put the source and binary files in subdirectories of
5051
`github.com/tarantool/go-tarantool` to the `import {...}` section at the start
5152
of any Go program.
5253

53-
<h2>API reference</h2>
54+
## Documentation
5455

5556
Read the [Tarantool documentation](tarantool-doc-data-model-url)
5657
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
6566
the [Tarantool CRUD operations](tarantool-doc-box-space-url).
6667
There are also Typed and Async versions of each data-manipulation function.
6768

68-
## Walking-through example in Go
69+
### API Reference
6970

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
7177
about what it does.
7278

7379
```go
74-
package main
80+
package tarantool
7581

7682
import (
77-
"fmt"
78-
"github.com/tarantool/go-tarantool"
83+
"fmt"
84+
"github.com/tarantool/go-tarantool"
7985
)
8086

8187
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+
}
9398
}
9499
```
95100

96-
**Observation 1:** the line "`github.com/tarantool/go-tarantool`" in the
101+
**Observation 1:** The line "`github.com/tarantool/go-tarantool`" in the
97102
`import(...)` section brings in all Tarantool-related functions and structures.
98103

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.
107108

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:
110111

111112
* a string with `host:port` format, and
112113
* the option structure that was set up earlier.
113114

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,
115116
otherwise it will have a description which can be retrieved with `err.Error()`.
116117

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
118119
"`conn.`" which is the name of the object that was returned by `Connect()`.
119120
There are two parameters:
120121

@@ -151,3 +152,4 @@ See feature comparison in [documentation](https://www.tarantool.io/en/doc/latest
151152
[go-tarantool]: https://github.com/tarantool/go-tarantool
152153
[tarantool-doc-data-model-url]: https://www.tarantool.io/en/doc/latest/book/box/data_model/
153154
[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

Comments
 (0)