-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.go
More file actions
50 lines (46 loc) · 1.22 KB
/
main.go
File metadata and controls
50 lines (46 loc) · 1.22 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
package main
import (
"fmt"
"os"
"time"
)
// 512 MiB
// const chunkSize = 536870912
func printHelp() {
fmt.Println("Usage:")
fmt.Println(" > split file:")
fmt.Println(" litsplitor s|split -f file_to_splitor -o where_split_files_storaged [-c chunkSizeInByte]")
fmt.Println(" > merge file:")
fmt.Println(" litsplitor m|merge -f where_split_files_storaged -o where_merged_file_storaged")
}
func main() {
appStartTime := time.Now().UnixMilli()
if len(os.Args) <= 1 {
printHelp()
return
}
a := os.Args[1]
fmt.Println("action", a)
if a == "split" || a == "s" {
f, o, c, err := getSplitParams(os.Args[2:])
if err != nil {
handleShouldToExitErr(err)
return
}
split(f, o, c)
} else if a == "merge" || a == "m" {
f, o, err := getMergeParams(os.Args[2:])
if err != nil {
handleShouldToExitErr(err)
return
}
merge(f, o)
} else {
fmt.Println("命令只能是 split(s) 或者 merge(m)")
}
appEndTime := time.Now().UnixMilli()
appProcessTime := appEndTime - appStartTime
appProcessTimeSeconds := appProcessTime / 1000
appProcessTimeMilliSeconds := appProcessTime - appProcessTimeSeconds*1000
fmt.Println("运行时间: ", appProcessTimeSeconds, "秒", appProcessTimeMilliSeconds, "毫秒")
}