mirror of
				https://github.com/matrix-org/gomatrix
				synced 2025-11-04 14:28:05 +00:00 
			
		
		
		
	Add userid example functions
This commit is contained in:
		
							parent
							
								
									52f7775d99
								
							
						
					
					
						commit
						76d9ae9611
					
				
					 1 changed files with 27 additions and 0 deletions
				
			
		
							
								
								
									
										27
									
								
								userids_examples_test.go
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										27
									
								
								userids_examples_test.go
									
										
									
									
									
										Normal file
									
								
							| 
						 | 
				
			
			@ -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
 | 
			
		||||
}
 | 
			
		||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue