From 76d9ae9611bd9142a05817f417d8df9719dc107e Mon Sep 17 00:00:00 2001 From: Kegan Dougal Date: Thu, 8 Dec 2016 17:41:35 +0000 Subject: [PATCH] Add userid example functions --- userids_examples_test.go | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100644 userids_examples_test.go diff --git a/userids_examples_test.go b/userids_examples_test.go new file mode 100644 index 0000000..6386b32 --- /dev/null +++ b/userids_examples_test.go @@ -0,0 +1,27 @@ +package gomatrix + +import "fmt" + +func ExampleEncodeUserLocalpart() { + localpart := EncodeUserLocalpart("Alph@Bet_50up") + fmt.Println(localpart) + // Output: _alph=40_bet__50up +} + +func ExampleDecodeUserLocalpart() { + localpart, err := DecodeUserLocalpart("_alph=40_bet__50up") + if err != nil { + panic(err) + } + fmt.Println(localpart) + // Output: Alph@Bet_50up +} + +func ExampleExtractUserLocalpart() { + localpart, err := ExtractUserLocalpart("@alice:matrix.org") + if err != nil { + panic(err) + } + fmt.Println(localpart) + // Output: alice +}