diff options
author | aunsane <aunsane@gmail.com> | 2018-04-27 21:33:17 +0300 |
---|---|---|
committer | aunsane <aunsane@gmail.com> | 2018-04-27 21:33:17 +0300 |
commit | e1ec72eab6d00b3ba38e5932bc88920f103b6e4a (patch) | |
tree | 999de2725a83e30fbbf6576200525d4ef0c5fe38 /protocols/Telegram/tdlib/td/example/go | |
parent | b9ce1d4d98525490ca1a38e2d9fd4f3369adb3e0 (diff) |
Telegram: initial commit
- tdlib moved to telegram dir
Diffstat (limited to 'protocols/Telegram/tdlib/td/example/go')
-rw-r--r-- | protocols/Telegram/tdlib/td/example/go/main.go | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/protocols/Telegram/tdlib/td/example/go/main.go b/protocols/Telegram/tdlib/td/example/go/main.go new file mode 100644 index 0000000000..430e067019 --- /dev/null +++ b/protocols/Telegram/tdlib/td/example/go/main.go @@ -0,0 +1,26 @@ +package main + +// #cgo LDFLAGS: -ltdjson +// #include <td/telegram/td_json_client.h> +import "C" +import ( + "log" + "unsafe" +) + +func td_send(client unsafe.Pointer, query *C.char) { + C.td_json_client_send(client, query) +} + +func td_receive(client unsafe.Pointer) string { + return C.GoString(C.td_json_client_receive(client, 1.0)) +} + +func main() { + var client unsafe.Pointer + client = C.td_json_client_create() + + query := C.CString(`{"@type": "getAuthorizationState"}`) + td_send(client, query) + log.Println(td_receive(client)) +} |