-
Notifications
You must be signed in to change notification settings - Fork 0
/
config.go
46 lines (38 loc) · 883 Bytes
/
config.go
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
package main
import (
"flag"
"log"
"runtime"
"strings"
)
type configSettings struct {
dirList []string
filePatterns []string
}
func setRuntime() {
log.Printf("Num of CPU: %d \n", runtime.NumCPU())
runtime.GOMAXPROCS(runtime.NumCPU())
}
func readSettings() configSettings {
var settings configSettings
var dirs string
var files string
flag.StringVar(&dirs, "dir", "", "-dir=dir,dir2")
flag.StringVar(&files, "ext", "*.*", "-ext=*.ext1,*.ext2")
flag.Parse()
if len(dirs) <= 0 {
log.Fatal("Root directory is not set:-dir=C:\\dir1,dir2")
}
settings.dirList = strings.Split(dirs, ",")
settings.filePatterns = strings.Split(files, ",")
isSet := false
for _, dir := range settings.dirList {
if len(dir) > 0 && isSet == false {
isSet = true
}
}
if isSet == false {
log.Fatal("Root directory is not set:-dir=C:\\dir1,dir2")
}
return settings
}