Skip to content

Commit 5eb024a

Browse files
committed
命令支持版本号查询
1 parent f7873a4 commit 5eb024a

File tree

3 files changed

+23
-6
lines changed

3 files changed

+23
-6
lines changed

tools/rddetector/build.bat

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,21 @@
11
@echo off
22

3-
mkdir target/
3+
RD /S/Q target >nul 2>nul
4+
MKDIR target
45

56
SET GOOS=windows
67
SET GOARCH=amd64
78
go build -ldflags "-s -w" -o target/rddetector.exe
9+
ECHO [+] Windows/amd64 rddetector.exe
810

911
SET GOOS=linux
1012
SET GOARCH=amd64
1113
go build -ldflags "-s -w" -o target/rddetector_linux_amd64
14+
ECHO [+] Linux/amd64 rddetector_linux_amd64
1215

1316
SET GOOS=linux
1417
SET GOARCH=arm64
1518
go build -ldflags "-s -w" -o target/rddetector_linux_arm64
19+
ECHO [+] Linux/arm64 rddetector_linux_arm64
1620

1721
@echo on

tools/rddetector/build.sh

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,9 @@
33
mkdir target/
44

55
GOOS=windows GOARCH=amd64 go build -ldflags "-s -w" -o target/rddetector.exe
6+
echo "[+] Windows/amd64 rddetector.exe"
67
GOOS=linux GOARCH=amd64 go build -ldflags "-s -w" -o target/rddetector_linux_amd64
8+
echo "[+] Linux/amd64 rddetector_linux_amd64"
79
GOOS=linux GOARCH=arm64 go build -ldflags "-s -w" -o target/rddetector_linux_arm64
10+
echo "[+] Linux/arm64 rddetector_linux_arm64"
811

tools/rddetector/main.go

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -33,13 +33,18 @@ func resultWriter(in <-chan *R, w io.StringWriter, wg *sync.WaitGroup) {
3333

3434
}
3535

36+
// Version 软件版本号
37+
const Version = "1.5.0"
38+
3639
var (
37-
inputPath string // 参数文件输入路径
38-
reportPath string // 生成的监测报告位置
39-
NumWorkers int // 工作线程数
40+
inputPath string // 参数文件输入路径
41+
reportPath string // 生成的监测报告位置
42+
NumWorkers int // 工作线程数
43+
VersionFlag bool // 版本号
4044
)
4145

4246
func init() {
47+
flag.BoolVar(&VersionFlag, "v", false, "检测工具版本")
4348
flag.StringVar(&inputPath, "i", "", "待检测随机数文件位置")
4449
flag.StringVar(&reportPath, "o", "RandomnessTestReport.csv", "待检测随机数文件位置")
4550
flag.IntVar(&NumWorkers, "n", runtime.NumCPU(), "工作线程数 (在大数据检测时通过该参数控制并行数量防止内存不足问题)")
@@ -48,20 +53,25 @@ func init() {
4853
log.SetPrefix("[rddetector] ")
4954
}
5055
func usage() {
51-
_, _ = fmt.Fprintf(os.Stderr, `randomness 随机性检测 rddetector 使用说明
56+
_, _ = fmt.Fprintf(os.Stderr, `randomness 随机性检测 rddetector v%s 使用说明
5257
5358
rddetector -i 待检测数据目录 [-o 生成报告位置]
5459
5560
示例: rddetector -i /data/target/ -o RandomnessTestReport.csv
5661
5762
数据规模将由程序自动推断,支持单文件规模 [20 000 bit, 1 000 000 bit, 100 000 000 bit]
5863
59-
`)
64+
`, Version)
6065
flag.PrintDefaults()
6166
}
6267

6368
func main() {
6469
flag.Parse()
70+
if VersionFlag {
71+
_, _ = fmt.Fprintf(os.Stderr, "rddetector v%s\n", Version)
72+
return
73+
}
74+
6575
if inputPath == "" {
6676
_, _ = fmt.Fprintf(os.Stderr, " -i 参数缺失\n\n")
6777
flag.Usage()

0 commit comments

Comments
 (0)