From 76fa23b9a46b663f1ce09af907ae259f38ed16a6 Mon Sep 17 00:00:00 2001 From: Kegan Dougal Date: Fri, 9 Dec 2016 16:09:48 +0000 Subject: [PATCH] Test example file --- client.go | 12 ------------ example_test.go | 17 +++++++++++++++++ 2 files changed, 17 insertions(+), 12 deletions(-) create mode 100644 example_test.go diff --git a/client.go b/client.go index 4266a7c..07c8d08 100644 --- a/client.go +++ b/client.go @@ -1,18 +1,6 @@ // Package gomatrix implements the Matrix Client-Server API. // // Specification can be found at http://matrix.org/docs/spec/client_server/r0.2.0.html -// -// Example usage of this library: (blocking version) -// cli, _ := gomatrix.NewClient("https://matrix.org", "@example:matrix.org", "MDAefhiuwehfuiwe") -// syncer := cli.Syncer.(*gomatrix.DefaultSyncer) -// syncer.OnEventType("m.room.message", func(ev *gomatrix.Event) { -// fmt.Println("Message: ", ev) -// }) -// if err := cli.Sync(); err != nil { -// fmt.Println("Sync() returned ", err) -// } -// -// To make the example non-blocking, call Sync() in a goroutine. package gomatrix import ( diff --git a/example_test.go b/example_test.go new file mode 100644 index 0000000..557f2b8 --- /dev/null +++ b/example_test.go @@ -0,0 +1,17 @@ +package gomatrix + +import ( + "fmt" +) + +func Example() { + cli, _ := NewClient("https://matrix.org", "@example:matrix.org", "MDAefhiuwehfuiwe") + syncer := cli.Syncer.(*DefaultSyncer) + syncer.OnEventType("m.room.message", func(ev *Event) { + fmt.Println("Message: ", ev) + }) + // To make the example non-blocking, call Sync() in a goroutine. + if err := cli.Sync(); err != nil { + fmt.Println("Sync() returned ", err) + } +}