I am trying to test whether a pattern is valid glob. How can we do that?
E.g. "^register/?$" this should return false.
I was trying to test like this but getting true.
package glob
import (
"fmt"
"github.com/gobwas/glob/compiler"
"github.com/gobwas/glob/syntax"
)
func isGlob (str string) bool {
delim := []rune{','}
if str == "" {
return false;
}
ast, err := syntax.Parse(str);
if err != nil {
return false
}
_, err := compiler.Compile(ast, delim)
if err == nil {
return true
}
return false
}
I am trying to test whether a pattern is valid glob. How can we do that?
E.g. "^register/?$" this should return false.
I was trying to test like this but getting true.