package osutils import ( "github.com/pkg/errors" "unicode" ) func UuidValidate(uuid string) error { if len(uuid) != 36 { return errors.New("uuid length not valid") } for i, r := range uuid { switch i { case 8, 13, 18, 23: if r != '-' { return errors.New("uuid separator not valid") } break default: if !isLetter(r) && !unicode.IsDigit(r) { return errors.Errorf("uuid char on %i not valid", i) } } } return nil } func isLetter(r rune) bool { l := unicode.ToLower(r) return (l >= 'a' && l <= 'z') }