Skip to content

Commit 87a008b

Browse files
committed
docs: describe regexMatcher functions
1 parent f54c0ac commit 87a008b

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

Diff for: parse/parse.go

+5
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@ func makeMatcher(tags map[string]interface{}) regexMatcher {
2222
return regs
2323
}
2424

25+
// FindTagIndex finds an index contained in the regex map and, if found, returns
26+
// the position of the tag in the string and the tag itself as an interface value
2527
func (r regexMatcher) FindTagIndex(str string) ([]int, interface{}) {
2628
lower := strings.ToLower(str)
2729
for reg, tag := range r {
@@ -32,13 +34,16 @@ func (r regexMatcher) FindTagIndex(str string) ([]int, interface{}) {
3234
return nil, nil
3335
}
3436

37+
// FindTag is a helper function for FindTagIndex which only returns the tag value itself
3538
func (r regexMatcher) FindTag(str string) interface{} {
3639
if _, t := r.FindTagIndex(str); t != nil {
3740
return t
3841
}
3942
return nil
4043
}
4144

45+
// FindAllTagsIndex find all tags in a string and returns two slices, the index positions
46+
// of the tags and the tag values themselves
4247
func (r regexMatcher) FindAllTagsIndex(str string) ([]int, []interface{}) {
4348
var tags []interface{}
4449
var idx []int

0 commit comments

Comments
 (0)