summaryrefslogtreecommitdiff
path: root/libs/tdlib/td/example/go/main.go
diff options
context:
space:
mode:
Diffstat (limited to 'libs/tdlib/td/example/go/main.go')
-rw-r--r--libs/tdlib/td/example/go/main.go26
1 files changed, 26 insertions, 0 deletions
diff --git a/libs/tdlib/td/example/go/main.go b/libs/tdlib/td/example/go/main.go
new file mode 100644
index 0000000000..430e067019
--- /dev/null
+++ b/libs/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))
+}