refactored newPattern()
parent
83fa66ddd9
commit
fbedc7e73f
|
@ -35,7 +35,9 @@ var (
|
||||||
// }
|
// }
|
||||||
func Compile(uncompiledPattern string) (*Pattern, error) {
|
func Compile(uncompiledPattern string) (*Pattern, error) {
|
||||||
|
|
||||||
pattern := newPattern(defaultFieldTagName)
|
var pattern Pattern
|
||||||
|
|
||||||
|
newPattern(&pattern, defaultFieldTagName)
|
||||||
|
|
||||||
s := uncompiledPattern
|
s := uncompiledPattern
|
||||||
for {
|
for {
|
||||||
|
@ -92,7 +94,7 @@ func Compile(uncompiledPattern string) (*Pattern, error) {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
return pattern, nil
|
return &pattern, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
19
pattern.go
19
pattern.go
|
@ -37,20 +37,21 @@ type Pattern struct {
|
||||||
fieldTagName string
|
fieldTagName string
|
||||||
}
|
}
|
||||||
|
|
||||||
func newPattern(fieldTagName string) *Pattern {
|
func newPattern(target *Pattern, fieldTagName string) error {
|
||||||
|
if nil == target {
|
||||||
|
return errNilTarget
|
||||||
|
}
|
||||||
|
|
||||||
bits := []string{}
|
bits := []string{}
|
||||||
names := []string{}
|
names := []string{}
|
||||||
namesSet := map[string]struct{}{}
|
namesSet := map[string]struct{}{}
|
||||||
|
|
||||||
pattern := Pattern{
|
target.bits = bits
|
||||||
bits:bits,
|
target.names = names
|
||||||
names:names,
|
target.namesSet = namesSet
|
||||||
namesSet:namesSet,
|
target.fieldTagName = fieldTagName
|
||||||
fieldTagName:fieldTagName,
|
|
||||||
}
|
|
||||||
|
|
||||||
return &pattern
|
|
||||||
|
|
||||||
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (pattern *Pattern) MatchNames() []string {
|
func (pattern *Pattern) MatchNames() []string {
|
||||||
|
|
Loading…
Reference in New Issue