mirror of
				https://github.com/usememos/memos.git
				synced 2025-10-31 00:38:08 +08:00 
			
		
		
		
	
		
			
				
	
	
		
			30 lines
		
	
	
	
		
			540 B
		
	
	
	
		
			Go
		
	
	
	
	
	
			
		
		
	
	
			30 lines
		
	
	
	
		
			540 B
		
	
	
	
		
			Go
		
	
	
	
	
	
| package common
 | |
| 
 | |
| import (
 | |
| 	"net/mail"
 | |
| 	"strings"
 | |
| 
 | |
| 	"github.com/google/uuid"
 | |
| )
 | |
| 
 | |
| // HasPrefixes returns true if the string s has any of the given prefixes.
 | |
| func HasPrefixes(src string, prefixes ...string) bool {
 | |
| 	for _, prefix := range prefixes {
 | |
| 		if strings.HasPrefix(src, prefix) {
 | |
| 			return true
 | |
| 		}
 | |
| 	}
 | |
| 	return false
 | |
| }
 | |
| 
 | |
| // ValidateEmail validates the email.
 | |
| func ValidateEmail(email string) bool {
 | |
| 	if _, err := mail.ParseAddress(email); err != nil {
 | |
| 		return false
 | |
| 	}
 | |
| 	return true
 | |
| }
 | |
| 
 | |
| func GenUUID() string {
 | |
| 	return uuid.New().String()
 | |
| }
 |