@@ -11,6 +11,20 @@ import (
11
11
"github.com/openset/leetcode/internal/client"
12
12
)
13
13
14
+ func InitTags () {
15
+ html := remember (problemsetAllFile , 7 , func () []byte {
16
+ return client .Get (problemsetAllUrl )
17
+ })
18
+ var tags []tagType
19
+ reg := regexp .MustCompile (`href="/tag/(\S+?)/"` )
20
+ for _ , matches := range reg .FindAllStringSubmatch (string (html ), - 1 ) {
21
+ if len (matches ) >= 2 {
22
+ tags = append (tags , tagType {Slug : matches [1 ]})
23
+ }
24
+ }
25
+ saveTags (tags , true )
26
+ }
27
+
14
28
func GetTags () (tags []tagType ) {
15
29
cts := fileGetContents ("tag/tags.json" )
16
30
jsonDecode (cts , & tags )
@@ -141,17 +155,3 @@ func (tag tagType) ShowName() string {
141
155
}
142
156
return tag .Name
143
157
}
144
-
145
- func init () {
146
- html := remember (problemsetAllFile , 7 , func () []byte {
147
- return client .Get (problemsetAllUrl )
148
- })
149
- var tags []tagType
150
- reg := regexp .MustCompile (`href="/tag/(\S+?)/"` )
151
- for _ , matches := range reg .FindAllStringSubmatch (string (html ), - 1 ) {
152
- if len (matches ) >= 2 {
153
- tags = append (tags , tagType {Slug : matches [1 ]})
154
- }
155
- }
156
- saveTags (tags , true )
157
- }
0 commit comments