-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.go
61 lines (52 loc) · 1.11 KB
/
main.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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
package main
import (
"fmt"
"os"
"path/filepath"
"strings"
)
func main() {
path, err := filepath.Abs(filepath.Dir(os.Args[0]))
if err != nil {
pressEnterExit(err)
}
print("path = ", path)
outFileName := "_out_" + filepath.Base(path) + ".go"
print("out file name = ", outFileName)
exePath := path
if len(os.Args) == 2 {
path = filepath.Join(path, os.Args[1])
}
dirFiles, err := MakeDirFiles(path)
if err != nil {
pressEnterExit(err)
return
}
goList := dirFiles.ListExt("go")
print("goList=", goList)
writer := MakeWriter()
for _, fname := range goList {
if strings.Contains(fname, "_test") || strings.HasPrefix(fname, "_") {
continue
}
goFile, err := ReadGoFile(path, fname)
if err != nil {
pressEnterExit(err)
return
}
writer.AddGoFile(goFile)
}
if err = writer.Write(exePath, outFileName); err != nil {
pressEnterExit(err)
return
}
}
// Prints error and ask user to press Enter to continue
func pressEnterExit(err error) {
if err != nil {
printf("ERROR: %v\n", err)
}
print("Нажмите Enter для выхода...")
var input string
fmt.Scanln(&input)
}