-
Notifications
You must be signed in to change notification settings - Fork 24
Expand file tree
/
Copy pathmain.go
More file actions
executable file
·87 lines (76 loc) · 1.79 KB
/
Copy pathmain.go
File metadata and controls
executable file
·87 lines (76 loc) · 1.79 KB
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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
package main
import (
"AICodeScan/Utils"
"AICodeScan/output"
"fmt"
"github.com/common-nighthawk/go-figure"
"github.com/fatih/color"
"strings"
"time"
)
func main() {
// 打印炫酷标题
myFigure := figure.NewFigure("AICodeScan", "", true)
printGradientFigure(myFigure.String())
//fmt.Println()
printGradient("\t\t\t\t\t\t\t\tby Zacarx")
start := time.Now()
// 启动扫描
Utils.Start()
output.OT()
// 计算扫描时间
defer func() {
elapsed := time.Since(start)
printGradient("扫描完成! 花费时长: %s\n", elapsed)
}()
}
// printGradientFigure 打印具有渐变颜色的文本(适用于 figure 字符串)
func printGradientFigure(text string) {
// 定义渐变颜色序列
colors := []color.Attribute{
color.FgHiGreen,
color.FgGreen,
color.FgYellow,
color.FgHiYellow,
color.FgHiRed,
color.FgRed,
}
// 获取每行文本
lines := strings.Split(text, "\n")
for _, line := range lines {
runes := []rune(line)
//runesLength := utf8.RuneCountInString(line)
for i, r := range runes {
idx := i % len(colors)
c := color.New(colors[idx])
c.Print(string(r))
}
fmt.Println()
}
}
// printGradient 打印具有渐变颜色的文本
func printGradient(format string, a ...interface{}) {
// 定义渐变颜色序列
colors := []color.Attribute{
color.FgHiGreen,
color.FgGreen,
color.FgYellow,
color.FgHiYellow,
color.FgHiRed,
color.FgRed,
}
// 获取格式化后的文本
text := fmt.Sprintf(format, a...)
runes := []rune(text)
//runesLength := utf8.RuneCountInString(text)
for i, r := range runes {
idx := i % len(colors)
c := color.New(colors[idx])
c.Print(string(r))
}
fmt.Println()
}
// 如果需要使用中文或特殊字符,确保正确处理
//func utf8.RuneCountInString(s string) int {
// return utf8.RuneCountInString(s)
//}