summaryrefslogtreecommitdiff
path: root/libs/tdlib/td/example/go/main.go
blob: 430e067019e70d7b270f09ec0fd368c42f1a8f44 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
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))
}