Personal Git forge.
package libimport "regexp"var HandleRegex = regexp.MustCompile("^[a-z0-9]+([-_][a-z0-9_]+)*$")const HandleMinLength = 3const HandleMaxLength = 30const UsernameMinLength = 2 const UsernameMaxLength = 40// validates a handle.func ValidateHandle(s string) bool { // check if the format is correct using the regex if !HandleRegex.MatchString(s) { return false } // length constraint? length := len(s) if length < HandleMinLength || length > HandleMaxLength { return false } return true}// validates a username.func ValidateUsername(s string) bool { length := len(s) if length < UsernameMinLength || length > UsernameMaxLength { return false } return true}