Polish code
This commit is contained in:
parent
8af3ab3fb6
commit
0870f8113a
10 changed files with 246 additions and 238 deletions
|
|
@ -21,7 +21,7 @@ func ClearUnprintableChars(s string, allowNewlines bool) string {
|
|||
}, s)
|
||||
}
|
||||
|
||||
var devNameRegexp = regexp.MustCompile("^[0-9a-z_-]+$")
|
||||
var devNameRegexp = regexp.MustCompile(`^[0-9a-z_-]+$`)
|
||||
|
||||
func ValidateDevName(s string) bool {
|
||||
// Allow mapped devices.
|
||||
|
|
@ -30,6 +30,12 @@ func ValidateDevName(s string) bool {
|
|||
return devNameRegexp.MatchString(s)
|
||||
}
|
||||
|
||||
var unixUsernameRegexp = regexp.MustCompile(`^[a-z_]([a-z0-9_-]{0,31}|[a-z0-9_-]{0,30}\$)$`)
|
||||
|
||||
func ValidateUnixUsername(s string) bool {
|
||||
return unixUsernameRegexp.MatchString(s)
|
||||
}
|
||||
|
||||
func Uint16ToBytesBE(v uint16) []byte {
|
||||
b := make([]byte, 2)
|
||||
binary.BigEndian.PutUint16(b, v)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue