Skip to content

Commit 5369293

Browse files
api example
1 parent 204fa0a commit 5369293

File tree

1 file changed

+38
-0
lines changed

1 file changed

+38
-0
lines changed

readme.md

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,44 @@ Usage of ./minetest_client:
4343
The username (default "test")
4444
```
4545

46+
# Api
47+
48+
```golang
49+
package main
50+
51+
import (
52+
"github.com/minetest-go/minetest_client/commandclient"
53+
)
54+
55+
func main() {
56+
host := "127.0.0.1"
57+
port := 30000
58+
username := "test"
59+
password := "test"
60+
61+
client := commandclient.NewCommandClient(host, port)
62+
err := client.Connect()
63+
if err != nil {
64+
panic(err)
65+
}
66+
67+
err = commandclient.Init(client, username)
68+
if err != nil {
69+
panic(err)
70+
}
71+
72+
err = commandclient.Login(client, username, password)
73+
if err != nil {
74+
panic(err)
75+
}
76+
77+
err = commandclient.ClientReady(client)
78+
if err != nil {
79+
panic(err)
80+
}
81+
}
82+
```
83+
4684
# License
4785

4886
MIT

0 commit comments

Comments
 (0)