Skip to content

Commit

Permalink
golang binding prove of concept
Browse files Browse the repository at this point in the history
  • Loading branch information
ldb authored and levlam committed Mar 19, 2018
1 parent 1ee13e2 commit 4753979
Showing 1 changed file with 26 additions and 0 deletions.
26 changes: 26 additions & 0 deletions example/go/main.go
Original file line number Diff line number Diff line change
@@ -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))
}

0 comments on commit 4753979

Please sign in to comment.