Test example file

This commit is contained in:
Kegan Dougal 2016-12-09 16:09:48 +00:00
parent 9c35a1edb8
commit 76fa23b9a4
2 changed files with 17 additions and 12 deletions

View File

@ -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 (

17
example_test.go Normal file
View File

@ -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)
}
}