Skip to content

Commit bfaa73e

Browse files
committed
[fmt] 调整变量名
1 parent cf745ef commit bfaa73e

File tree

1 file changed

+18
-18
lines changed

1 file changed

+18
-18
lines changed

main.go

+18-18
Original file line numberDiff line numberDiff line change
@@ -18,14 +18,14 @@ import (
1818
// by Rytia <admin@zzfly.net>, 2021-07-17 周六
1919

2020
var (
21-
wg sync.WaitGroup
22-
result sync.Map
23-
totalFile uint32
24-
errFile uint32
21+
processLintWg sync.WaitGroup
22+
lintErrResult sync.Map
23+
totalFileCounter uint32
24+
errFileCounter uint32
2525
)
2626

2727
// PHP 可执行文件路径
28-
var phpExecutor string = "php"
28+
var phpExecutor = "php"
2929

3030
// 控制最大运行协程个数
3131
var ch = make(chan bool, 8)
@@ -63,10 +63,10 @@ func main() {
6363
}
6464
}
6565

66-
wg.Wait()
66+
processLintWg.Wait()
6767
printResult()
6868

69-
if errFile > 0 {
69+
if errFileCounter > 0 {
7070
os.Exit(StatusCoedFilesError)
7171
}
7272
os.Exit(0)
@@ -88,13 +88,13 @@ func printWelcome() {
8888
func printResult() {
8989
fmt.Println("\n---------------------------")
9090
fmt.Println("Result:")
91-
fmt.Printf("Check: %d / Errors: %d \n", totalFile, errFile)
91+
fmt.Printf("Check: %d / Errors: %d \n", totalFileCounter, errFileCounter)
9292

93-
if errFile > 0 {
94-
result.Range(processResultPrint)
93+
if errFileCounter > 0 {
94+
lintErrResult.Range(processResultPrint)
9595
}
9696

97-
fmt.Println("\n")
97+
fmt.Println()
9898
}
9999

100100
// 获取执行目录下的文件,执行检测
@@ -111,7 +111,7 @@ func lintPath(path string, recursive bool) {
111111
if recursive && file.IsDir() {
112112
lintPath(path+"/"+file.Name(), recursive)
113113
} else if strings.Contains(file.Name(), ".php") {
114-
wg.Add(1)
114+
processLintWg.Add(1)
115115
go processPhpLint(path, file.Name())
116116
}
117117
}
@@ -142,7 +142,7 @@ func lintGit() {
142142
for _, file := range gitDiffFiles {
143143
// 防止空串影响
144144
if len(file) != 0 {
145-
wg.Add(1)
145+
processLintWg.Add(1)
146146
go processPhpLint(gitRootPath, file)
147147
}
148148
}
@@ -169,15 +169,15 @@ func lintSvn() {
169169
for _, file := range svnDiffFiles {
170170
// 防止空串影响
171171
if len(file) != 0 {
172-
wg.Add(1)
172+
processLintWg.Add(1)
173173
go processPhpLint(svnPath, file)
174174
}
175175
}
176176
}
177177

178178
// 处理 PHP 语法检测
179179
func processPhpLint(path string, file string) {
180-
defer wg.Done()
180+
defer processLintWg.Done()
181181

182182
// 控制最大协程数
183183
ch <- true
@@ -193,13 +193,13 @@ func processPhpLint(path string, file string) {
193193

194194
if err != nil {
195195
fmt.Println(color.HiRedString("[ERR]"), file, err.Error())
196-
result.Store(path+"/"+file, string(stdout))
197-
atomic.AddUint32(&errFile, 1)
196+
lintErrResult.Store(path+"/"+file, stdout)
197+
atomic.AddUint32(&errFileCounter, 1)
198198
} else {
199199
fmt.Println(color.HiGreenString("[OK] "), file)
200200
}
201201

202-
atomic.AddUint32(&totalFile, 1)
202+
atomic.AddUint32(&totalFileCounter, 1)
203203

204204
<-ch
205205
}

0 commit comments

Comments
 (0)