-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.go
More file actions
41 lines (39 loc) · 917 Bytes
/
main.go
File metadata and controls
41 lines (39 loc) · 917 Bytes
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
package main
import (
"fmt"
"os"
"strings"
)
func main() {
var (
orignFile string
fakeCodeFile string
)
if len(os.Args) < 3 {
fmt.Printf("orign file path\n>")
var text string
fmt.Scan(&text)
orignFile = text
fmt.Printf("fake code file path\n>")
fmt.Scan(&text)
fakeCodeFile = text
} else {
orignFile = os.Args[1]
fakeCodeFile = os.Args[2]
}
raw, _ := os.ReadFile(orignFile)
lines := strings.Split(string(raw), "\r\n")
rawcode := make([][]string, 0)
for _, l := range lines {
if l != "" {
line := strings.Split(l, " ")
rawcode = append(rawcode, line)
}
}
code := srcGen(rawcode)
source := code.Build()
fmt.Println("--------------------------------------------------------------------------------\n" + source + "--------------------------------------------------------------------------------")
f, _ := os.Create(fakeCodeFile)
f.Write([]byte(source))
f.Close()
}