-
Notifications
You must be signed in to change notification settings - Fork 0
/
has_tags.go
45 lines (40 loc) · 843 Bytes
/
has_tags.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
package main
import (
"os"
"strings"
)
type hasTags struct {
tags string
}
func (h hasTags) getAllTags() []string {
result := strings.Split(h.tags, string(os.PathSeparator))
if result[len(result)-1] == contentTag || result[len(result)-1] == allTagsTag {
result = result[:len(result)-1]
}
return result
}
func (h hasTags) getTagsWithNegative() (positive []string, negative []string) {
allTags := h.getAllTags()
nextIsNegative := false
for _, tag := range allTags {
if nextIsNegative {
if tag != "" {
negative = append(negative, tag)
}
nextIsNegative = false
} else {
if tag == negativeTag {
nextIsNegative = true
} else {
if tag != "" {
positive = append(positive, tag)
}
}
}
}
return
}
func (h hasTags) getTags() []string {
result, _ := h.getTagsWithNegative()
return result
}