go-pathmatch/pattern_glob.go

29 lines
406 B
Go
Raw Permalink Normal View History

2019-06-21 20:37:53 +00:00
package pathmatch
import (
"bytes"
)
func (pattern *Pattern) Glob() string {
if nil == pattern {
return ""
}
pattern.mutex.RLock()
defer pattern.mutex.RUnlock()
//@TODO: This shouldn't be executed every time!
var buffer bytes.Buffer
for _, bit := range pattern.bits {
if wildcardBit == bit {
buffer.WriteRune('*')
} else {
buffer.WriteString(bit)
}
}
return buffer.String()
}