Skip to content

Commit ce4286a

Browse files
committed
Fix ctl module
1 parent 3442d3a commit ce4286a

15 files changed

+96
-66
lines changed

ctl/label.go

+10-9
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import (
1010
"regexp"
1111
"strings"
1212

13+
"github.com/halfrost/LeetCode-Go/ctl/util"
1314
"github.com/spf13/cobra"
1415
)
1516

@@ -75,7 +76,7 @@ var (
7576
)
7677

7778
func getChapterFourFileOrder() ([]string, []int) {
78-
solutions, solutionIds := LoadChapterFourDir()
79+
solutions, solutionIds := util.LoadChapterFourDir()
7980
chapterFourFileOrder := []string{"_index"}
8081
chapterFourFileOrder = append(chapterFourFileOrder, solutions...)
8182
fmt.Printf("ChapterFour 中包括 _index 有 %v 个文件, len(id) = %v\n", len(chapterFourFileOrder), len(solutionIds))
@@ -149,34 +150,34 @@ func addPreNextLabel(order, preOrder []string, chapterFourIds []int, preChapter,
149150
tmp = "\n\n" + delLine + fmt.Sprintf("<p align = \"right\"><a href=\"https://books.halfrost.com/leetcode/%v/%v/\">下一页➡️</a></p>\n", chapter, order[index+1])
150151
} else {
151152
if chapter == "ChapterFour" {
152-
tmp = "\n\n" + preNextHeader + fmt.Sprintf("<p><a href=\"https://books.halfrost.com/leetcode/%v/%v/\">⬅️上一章</a></p>\n", preChapter, preOrder[len(preOrder)-1]) + fmt.Sprintf("<p><a href=\"https://books.halfrost.com/leetcode/%v/%v/%v/\">下一页➡️</a></p>\n", chapter, GetChpaterFourFileNum(chapterFourIds[(index-1)+1]), order[index+1]) + preNextFotter
153+
tmp = "\n\n" + preNextHeader + fmt.Sprintf("<p><a href=\"https://books.halfrost.com/leetcode/%v/%v/\">⬅️上一章</a></p>\n", preChapter, preOrder[len(preOrder)-1]) + fmt.Sprintf("<p><a href=\"https://books.halfrost.com/leetcode/%v/%v/%v/\">下一页➡️</a></p>\n", chapter, util.GetChpaterFourFileNum(chapterFourIds[(index-1)+1]), order[index+1]) + preNextFotter
153154
} else {
154155
tmp = "\n\n" + preNextHeader + fmt.Sprintf("<p><a href=\"https://books.halfrost.com/leetcode/%v/%v/\">⬅️上一章</a></p>\n", preChapter, preOrder[len(preOrder)-1]) + fmt.Sprintf("<p><a href=\"https://books.halfrost.com/leetcode/%v/%v/\">下一页➡️</a></p>\n", chapter, order[index+1]) + preNextFotter
155156
}
156157
}
157158
} else if index == len(order)-1 {
158159
if chapter == "ChapterFour" {
159160
// 最后一页不需要“下一页”
160-
tmp = "\n\n" + delLine + fmt.Sprintf("<p><a href=\"https://books.halfrost.com/leetcode/%v/%v/%v/\">⬅️上一页</a></p>\n", chapter, GetChpaterFourFileNum(chapterFourIds[(index-1)-1]), order[index-1])
161+
tmp = "\n\n" + delLine + fmt.Sprintf("<p><a href=\"https://books.halfrost.com/leetcode/%v/%v/%v/\">⬅️上一页</a></p>\n", chapter, util.GetChpaterFourFileNum(chapterFourIds[(index-1)-1]), order[index-1])
161162
} else {
162163
tmp = "\n\n" + preNextHeader + fmt.Sprintf("<p><a href=\"https://books.halfrost.com/leetcode/%v/%v/\">⬅️上一页</a></p>\n", chapter, order[index-1]) + fmt.Sprintf("<p><a href=\"https://books.halfrost.com/leetcode/%v/\">下一章➡️</a></p>\n", nextChapter) + preNextFotter
163164
}
164165
} else if index == 1 {
165166
if chapter == "ChapterFour" {
166-
tmp = "\n\n" + preNextHeader + fmt.Sprintf("<p><a href=\"https://books.halfrost.com/leetcode/%v/\">⬅️上一页</a></p>\n", chapter) + fmt.Sprintf("<p><a href=\"https://books.halfrost.com/leetcode/%v/%v/%v/\">下一页➡️</a></p>\n", chapter, GetChpaterFourFileNum(chapterFourIds[(index-1)+1]), order[index+1]) + preNextFotter
167+
tmp = "\n\n" + preNextHeader + fmt.Sprintf("<p><a href=\"https://books.halfrost.com/leetcode/%v/\">⬅️上一页</a></p>\n", chapter) + fmt.Sprintf("<p><a href=\"https://books.halfrost.com/leetcode/%v/%v/%v/\">下一页➡️</a></p>\n", chapter, util.GetChpaterFourFileNum(chapterFourIds[(index-1)+1]), order[index+1]) + preNextFotter
167168
} else {
168169
tmp = "\n\n" + preNextHeader + fmt.Sprintf("<p><a href=\"https://books.halfrost.com/leetcode/%v/\">⬅️上一页</a></p>\n", chapter) + fmt.Sprintf("<p><a href=\"https://books.halfrost.com/leetcode/%v/%v/\">下一页➡️</a></p>\n", chapter, order[index+1]) + preNextFotter
169170
}
170171
} else {
171172
if chapter == "ChapterFour" {
172-
tmp = "\n\n" + preNextHeader + fmt.Sprintf("<p><a href=\"https://books.halfrost.com/leetcode/%v/%v/%v/\">⬅️上一页</a></p>\n", chapter, GetChpaterFourFileNum(chapterFourIds[(index-1)-1]), order[index-1]) + fmt.Sprintf("<p><a href=\"https://books.halfrost.com/leetcode/%v/%v/%v/\">下一页➡️</a></p>\n", chapter, GetChpaterFourFileNum(chapterFourIds[(index-1)+1]), order[index+1]) + preNextFotter
173+
tmp = "\n\n" + preNextHeader + fmt.Sprintf("<p><a href=\"https://books.halfrost.com/leetcode/%v/%v/%v/\">⬅️上一页</a></p>\n", chapter, util.GetChpaterFourFileNum(chapterFourIds[(index-1)-1]), order[index-1]) + fmt.Sprintf("<p><a href=\"https://books.halfrost.com/leetcode/%v/%v/%v/\">下一页➡️</a></p>\n", chapter, util.GetChpaterFourFileNum(chapterFourIds[(index-1)+1]), order[index+1]) + preNextFotter
173174
} else {
174175
tmp = "\n\n" + preNextHeader + fmt.Sprintf("<p><a href=\"https://books.halfrost.com/leetcode/%v/%v/\">⬅️上一页</a></p>\n", chapter, order[index-1]) + fmt.Sprintf("<p><a href=\"https://books.halfrost.com/leetcode/%v/%v/\">下一页➡️</a></p>\n", chapter, order[index+1]) + preNextFotter
175176
}
176177
}
177178

178179
if chapter == "ChapterFour" && index > 0 {
179-
path = fmt.Sprintf("%v/%v", GetChpaterFourFileNum(chapterFourIds[(index-1)]), path)
180+
path = fmt.Sprintf("%v/%v", util.GetChpaterFourFileNum(chapterFourIds[(index-1)]), path)
180181
}
181182

182183
exist, err = needAdd(fmt.Sprintf("../website/content/%v/%v.md", chapter, path))
@@ -191,7 +192,7 @@ func addPreNextLabel(order, preOrder []string, chapterFourIds []int, preChapter,
191192
fmt.Println(err)
192193
return
193194
}
194-
WriteFile(fmt.Sprintf("../website/content/%v/%v.md", chapter, path), res)
195+
util.WriteFile(fmt.Sprintf("../website/content/%v/%v.md", chapter, path), res)
195196
count++
196197
}
197198
}
@@ -241,7 +242,7 @@ func delPreNextLabel(order []string, chapterFourIds []int, chapter string) {
241242
lineNum = 3
242243
}
243244
if chapter == "ChapterFour" && index > 0 {
244-
path = fmt.Sprintf("%v/%v", GetChpaterFourFileNum(chapterFourIds[(index-1)]), path)
245+
path = fmt.Sprintf("%v/%v", util.GetChpaterFourFileNum(chapterFourIds[(index-1)]), path)
245246
}
246247

247248
exist, err := needAdd(fmt.Sprintf("../website/content/%v/%v.md", chapter, path))
@@ -262,7 +263,7 @@ func delPreNextLabel(order []string, chapterFourIds []int, chapter string) {
262263
// fmt.Println(err)
263264
// return
264265
// }
265-
// WriteFile(fmt.Sprintf("../website/content/ChapterOne/%v.md", v), res)
266+
// util.WriteFile(fmt.Sprintf("../website/content/ChapterOne/%v.md", v), res)
266267
}
267268

268269
func needAdd(filePath string) (bool, error) {

ctl/models/go.mod

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
module github.com/halfrost/LeetCode-Go/ctl/models
2+
3+
go 1.19
4+
5+
replace github.com/halfrost/LeetCode-Go/ctl/models => ../util
6+
7+
require github.com/halfrost/LeetCode-Go/ctl/util v0.0.0-20220910225043-e3bb5aff34d0

ctl/models/go.sum

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
github.com/halfrost/LeetCode-Go/ctl/util v0.0.0-20220910225043-e3bb5aff34d0 h1:WAOAj59szR52uAnEQljAt7ucpbGGOsy0xgR/NeP4Xbc=
2+
github.com/halfrost/LeetCode-Go/ctl/util v0.0.0-20220910225043-e3bb5aff34d0/go.mod h1:+cA8KYcbGxP2Itd3NG+QJVGL/MEZISKlei0tvgDeEag=

ctl/lcproblems.go ctl/models/lcproblems.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package main
1+
package models
22

33
import (
44
"fmt"

ctl/mdrow.go ctl/models/mdrow.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package main
1+
package models
22

33
import (
44
"fmt"

ctl/tagproblem.go ctl/models/tagproblem.go

+6-4
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,12 @@
1-
package main
1+
package models
22

33
import (
44
"encoding/json"
55
"fmt"
66
"strconv"
77
"strings"
8+
9+
"github.com/halfrost/LeetCode-Go/ctl/util"
810
)
911

1012
// Graphql define
@@ -152,15 +154,15 @@ func standardizedTitle(orig string, frontendQuestionID int32) string {
152154
func GenerateTagMdRows(solutionIds []int, metaMap map[int]TagList, mdrows []Mdrow, internal bool) []TagList {
153155
tl := []TagList{}
154156
for _, row := range mdrows {
155-
if BinarySearch(solutionIds, int(row.FrontendQuestionID)) != -1 {
157+
if util.BinarySearch(solutionIds, int(row.FrontendQuestionID)) != -1 {
156158
tmp := TagList{}
157159
tmp.FrontendQuestionID = row.FrontendQuestionID
158160
tmp.QuestionTitle = strings.TrimSpace(row.QuestionTitle)
159161
s7 := standardizedTitle(row.QuestionTitle, row.FrontendQuestionID)
160162
if internal {
161-
tmp.SolutionPath = fmt.Sprintf("[Go]({{< relref \"/ChapterFour/%v/%v.md\" >}})", GetChpaterFourFileNum(int(row.FrontendQuestionID)), fmt.Sprintf("%04d.%v", int(row.FrontendQuestionID), s7))
163+
tmp.SolutionPath = fmt.Sprintf("[Go]({{< relref \"/ChapterFour/%v/%v.md\" >}})", util.GetChpaterFourFileNum(int(row.FrontendQuestionID)), fmt.Sprintf("%04d.%v", int(row.FrontendQuestionID), s7))
162164
} else {
163-
tmp.SolutionPath = fmt.Sprintf("[Go](https://books.halfrost.com/leetcode/ChapterFour/%v/%v)", GetChpaterFourFileNum(int(row.FrontendQuestionID)), fmt.Sprintf("%04d.%v", int(row.FrontendQuestionID), s7))
165+
tmp.SolutionPath = fmt.Sprintf("[Go](https://books.halfrost.com/leetcode/ChapterFour/%v/%v)", util.GetChpaterFourFileNum(int(row.FrontendQuestionID)), fmt.Sprintf("%04d.%v", int(row.FrontendQuestionID), s7))
164166
}
165167
tmp.Acceptance = row.Acceptance
166168
tmp.Difficulty = row.Difficulty

ctl/user.go ctl/models/user.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package main
1+
package models
22

33
import (
44
"fmt"

ctl/pdf.go

+8-7
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import (
1010
"strconv"
1111
"strings"
1212

13+
"github.com/halfrost/LeetCode-Go/ctl/util"
1314
"github.com/spf13/cobra"
1415
)
1516

@@ -60,7 +61,7 @@ func generatePDF() {
6061
// 先删除 pre-next
6162
delPreNext()
6263

63-
chapterFourFileOrder, _ := LoadChapterFourDir()
64+
chapterFourFileOrder, _ := util.LoadChapterFourDir()
6465
totalSolutions = len(chapterFourFileOrder)
6566
midVersion = totalSolutions / 100
6667
lastVersion = totalSolutions % 100
@@ -79,18 +80,18 @@ func generatePDF() {
7980
tmp, err = loadChapter(chapterThreeFileOrder, "./pdftemp", "ChapterThree")
8081
pdf = append(pdf, tmp...)
8182
// PDF 第四章
82-
tmp, err = LoadFile("./pdftemp/ChapterFour/_index.md")
83+
tmp, err = util.LoadFile("./pdftemp/ChapterFour/_index.md")
8384
pdf = append(pdf, tmp...)
8485
tmp, err = loadChapter(chapterFourFileOrder, "../website/content", "ChapterFour")
8586
pdf = append(pdf, tmp...)
8687
if err != nil {
8788
fmt.Println(err)
8889
}
8990
// 生成 PDF
90-
WriteFile(fmt.Sprintf("../PDF v%v.%v.%v.md", majorVersion, midVersion, lastVersion), pdf)
91+
util.WriteFile(fmt.Sprintf("../PDF v%v.%v.%v.md", majorVersion, midVersion, lastVersion), pdf)
9192
// 还原现场
9293
addPreNext()
93-
DestoryDir("./pdftemp")
94+
util.DestoryDir("./pdftemp")
9495
}
9596

9697
func loadChapter(order []string, path, chapter string) ([]byte, error) {
@@ -109,10 +110,10 @@ func loadChapter(order []string, path, chapter string) ([]byte, error) {
109110
if err != nil {
110111
fmt.Println(err)
111112
}
112-
tmp, err = LoadFile(fmt.Sprintf("%v/%v/%v/%v.md", path, chapter, GetChpaterFourFileNum(num), v))
113+
tmp, err = util.LoadFile(fmt.Sprintf("%v/%v/%v/%v.md", path, chapter, util.GetChpaterFourFileNum(num), v))
113114
}
114115
} else {
115-
tmp, err = LoadFile(fmt.Sprintf("%v/%v/%v.md", path, chapter, v))
116+
tmp, err = util.LoadFile(fmt.Sprintf("%v/%v/%v.md", path, chapter, v))
116117
}
117118
}
118119
if err != nil {
@@ -146,7 +147,7 @@ func prepare(path string) {
146147
}
147148
// 生成外部链接的 ChapterTwo
148149
buildChapterTwo(false)
149-
CopyFile("./pdftemp/ChapterTwo/_index.md", "../website/content/ChapterTwo/_index.md")
150+
util.CopyFile("./pdftemp/ChapterTwo/_index.md", "../website/content/ChapterTwo/_index.md")
150151

151152
for _, v := range chapterTwoFileOrder {
152153
removeHeader(fmt.Sprintf("./pdftemp/ChapterTwo/%v.md", v), fmt.Sprintf("./pdftemp/ChapterTwo/%v.md", v), 5)

ctl/render.go

+36-34
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@ import (
1111
"strconv"
1212
"strings"
1313

14+
m "github.com/halfrost/LeetCode-Go/ctl/models"
15+
"github.com/halfrost/LeetCode-Go/ctl/util"
1416
"github.com/spf13/cobra"
1517
)
1618

@@ -78,13 +80,13 @@ func newBuildMenu() *cobra.Command {
7880

7981
func buildREADME() {
8082
var (
81-
problems []StatStatusPairs
82-
lpa LeetCodeProblemAll
83-
info UserInfo
83+
problems []m.StatStatusPairs
84+
lpa m.LeetCodeProblemAll
85+
info m.UserInfo
8486
)
8587
// 请求所有题目信息
8688
body := getProblemAllList()
87-
problemsMap, optimizingIds := map[int]StatStatusPairs{}, []int{}
89+
problemsMap, optimizingIds := map[int]m.StatStatusPairs{}, []int{}
8890
err := json.Unmarshal(body, &lpa)
8991
if err != nil {
9092
fmt.Println(err)
@@ -94,30 +96,30 @@ func buildREADME() {
9496

9597
// 拼凑 README 需要渲染的数据
9698
problems = lpa.StatStatusPairs
97-
info = ConvertUserInfoModel(lpa)
99+
info = m.ConvertUserInfoModel(lpa)
98100
for _, v := range problems {
99101
problemsMap[int(v.Stat.FrontendQuestionID)] = v
100102
}
101-
mdrows := ConvertMdModelFromSsp(problems)
102-
sort.Sort(SortByQuestionID(mdrows))
103-
solutionIds, _, try := LoadSolutionsDir()
104-
GenerateMdRows(solutionIds, mdrows)
103+
mdrows := m.ConvertMdModelFromSsp(problems)
104+
sort.Sort(m.SortByQuestionID(mdrows))
105+
solutionIds, _, try := util.LoadSolutionsDir()
106+
m.GenerateMdRows(solutionIds, mdrows)
105107
info.EasyTotal, info.MediumTotal, info.HardTotal, info.OptimizingEasy, info.OptimizingMedium, info.OptimizingHard, optimizingIds = statisticalData(problemsMap, solutionIds)
106-
omdrows := ConvertMdModelFromIds(problemsMap, optimizingIds)
107-
sort.Sort(SortByQuestionID(omdrows))
108+
omdrows := m.ConvertMdModelFromIds(problemsMap, optimizingIds)
109+
sort.Sort(m.SortByQuestionID(omdrows))
108110

109111
// 按照模板渲染 README
110-
res, err := renderReadme("./template/template.markdown", len(solutionIds), try, Mdrows{Mdrows: mdrows}, Mdrows{Mdrows: omdrows}, info)
112+
res, err := renderReadme("./template/template.markdown", len(solutionIds), try, m.Mdrows{Mdrows: mdrows}, m.Mdrows{Mdrows: omdrows}, info)
111113
if err != nil {
112114
fmt.Println(err)
113115
return
114116
}
115-
WriteFile("../README.md", res)
117+
util.WriteFile("../README.md", res)
116118
fmt.Println("write file successful")
117119
//makeReadmeFile(mds)
118120
}
119121

120-
func renderReadme(filePath string, total, try int, mdrows, omdrows Mdrows, user UserInfo) ([]byte, error) {
122+
func renderReadme(filePath string, total, try int, mdrows, omdrows m.Mdrows, user m.UserInfo) ([]byte, error) {
121123
f, err := os.OpenFile(filePath, os.O_RDONLY, 0644)
122124
if err != nil {
123125
return nil, err
@@ -165,8 +167,8 @@ func renderReadme(filePath string, total, try int, mdrows, omdrows Mdrows, user
165167
// false 渲染的链接是外部 HTTPS 链接,用于生成 PDF
166168
func buildChapterTwo(internal bool) {
167169
var (
168-
gr GraphQLResp
169-
questions []Question
170+
gr m.GraphQLResp
171+
questions []m.Question
170172
count int
171173
)
172174
for index, tag := range chapterTwoSlug {
@@ -178,39 +180,39 @@ func buildChapterTwo(internal bool) {
178180
return
179181
}
180182
questions = gr.Data.TopicTag.Questions
181-
mdrows := ConvertMdModelFromQuestions(questions)
182-
sort.Sort(SortByQuestionID(mdrows))
183-
solutionIds, _, _ := LoadSolutionsDir()
183+
mdrows := m.ConvertMdModelFromQuestions(questions)
184+
sort.Sort(m.SortByQuestionID(mdrows))
185+
solutionIds, _, _ := util.LoadSolutionsDir()
184186
tl, err := loadMetaData(fmt.Sprintf("./meta/%v", chapterTwoFileName[index]))
185187
if err != nil {
186188
fmt.Printf("err = %v\n", err)
187189
}
188-
tls := GenerateTagMdRows(solutionIds, tl, mdrows, internal)
190+
tls := m.GenerateTagMdRows(solutionIds, tl, mdrows, internal)
189191
//fmt.Printf("tls = %v\n", tls)
190192
// 按照模板渲染 README
191-
res, err := renderChapterTwo(fmt.Sprintf("./template/%v.md", chapterTwoFileName[index]), TagLists{TagLists: tls})
193+
res, err := renderChapterTwo(fmt.Sprintf("./template/%v.md", chapterTwoFileName[index]), m.TagLists{TagLists: tls})
192194
if err != nil {
193195
fmt.Println(err)
194196
return
195197
}
196198
if internal {
197-
WriteFile(fmt.Sprintf("../website/content/ChapterTwo/%v.md", chapterTwoFileName[index]), res)
199+
util.WriteFile(fmt.Sprintf("../website/content/ChapterTwo/%v.md", chapterTwoFileName[index]), res)
198200
} else {
199-
WriteFile(fmt.Sprintf("./pdftemp/ChapterTwo/%v.md", chapterTwoFileName[index]), res)
201+
util.WriteFile(fmt.Sprintf("./pdftemp/ChapterTwo/%v.md", chapterTwoFileName[index]), res)
200202
}
201203

202204
count++
203205
}
204206
fmt.Printf("write %v files successful", count)
205207
}
206208

207-
func loadMetaData(filePath string) (map[int]TagList, error) {
209+
func loadMetaData(filePath string) (map[int]m.TagList, error) {
208210
f, err := os.OpenFile(filePath, os.O_RDONLY, 0644)
209211
if err != nil {
210212
return nil, err
211213
}
212214
defer f.Close()
213-
reader, metaMap := bufio.NewReader(f), map[int]TagList{}
215+
reader, metaMap := bufio.NewReader(f), map[int]m.TagList{}
214216

215217
for {
216218
line, _, err := reader.ReadLine()
@@ -223,7 +225,7 @@ func loadMetaData(filePath string) (map[int]TagList, error) {
223225
s := strings.Split(string(line), "|")
224226
v, _ := strconv.Atoi(strings.Split(s[1], ".")[0])
225227
// v[0] 是题号,s[4] time, s[5] space, s[6] favorite
226-
metaMap[v] = TagList{
228+
metaMap[v] = m.TagList{
227229
FrontendQuestionID: int32(v),
228230
Acceptance: "",
229231
Difficulty: "",
@@ -234,7 +236,7 @@ func loadMetaData(filePath string) (map[int]TagList, error) {
234236
}
235237
}
236238

237-
func renderChapterTwo(filePath string, tls TagLists) ([]byte, error) {
239+
func renderChapterTwo(filePath string, tls m.TagLists) ([]byte, error) {
238240
f, err := os.OpenFile(filePath, os.O_RDONLY, 0644)
239241
if err != nil {
240242
return nil, err
@@ -270,18 +272,18 @@ func buildBookMenu() {
270272
fmt.Println(err)
271273
return
272274
}
273-
WriteFile("../website/content/menu/index.md", res)
275+
util.WriteFile("../website/content/menu/index.md", res)
274276
fmt.Println("generate Menu successful")
275277
}
276278

277279
// 拷贝 leetcode 目录下的题解 README 文件至第四章对应文件夹中
278280
func copyLackFile() {
279-
solutionIds, soName, _ := LoadSolutionsDir()
280-
_, ch4Ids := LoadChapterFourDir()
281+
solutionIds, soName, _ := util.LoadSolutionsDir()
282+
_, ch4Ids := util.LoadChapterFourDir()
281283

282284
needCopy := []string{}
283285
for i := 0; i < len(solutionIds); i++ {
284-
if BinarySearch(ch4Ids, solutionIds[i]) == -1 {
286+
if util.BinarySearch(ch4Ids, solutionIds[i]) == -1 {
285287
needCopy = append(needCopy, soName[i])
286288
}
287289
}
@@ -293,12 +295,12 @@ func copyLackFile() {
293295
if err != nil {
294296
fmt.Println(err)
295297
}
296-
err = os.MkdirAll(fmt.Sprintf("../website/content/ChapterFour/%v", GetChpaterFourFileNum(tmp)), os.ModePerm)
298+
err = os.MkdirAll(fmt.Sprintf("../website/content/ChapterFour/%v", util.GetChpaterFourFileNum(tmp)), os.ModePerm)
297299
if err != nil {
298300
fmt.Println(err)
299301
}
300-
CopyFile(fmt.Sprintf("../website/content/ChapterFour/%v/%v.md", GetChpaterFourFileNum(tmp), needCopy[i]), fmt.Sprintf("../leetcode/%v/README.md", needCopy[i]))
301-
CopyFile(fmt.Sprintf("../website/content/ChapterFour/%v/_index.md", GetChpaterFourFileNum(tmp)), "./template/collapseSection.md")
302+
util.CopyFile(fmt.Sprintf("../website/content/ChapterFour/%v/%v.md", util.GetChpaterFourFileNum(tmp), needCopy[i]), fmt.Sprintf("../leetcode/%v/README.md", needCopy[i]))
303+
util.CopyFile(fmt.Sprintf("../website/content/ChapterFour/%v/_index.md", util.GetChpaterFourFileNum(tmp)), "./template/collapseSection.md")
302304
}
303305
}
304306
} else {

0 commit comments

Comments
 (0)