-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.go
46 lines (38 loc) · 790 Bytes
/
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
package main
import (
"fmt"
"log"
"os"
"sample/utils"
"text/template"
)
type TemplateData struct {
UserName string
ProjectName string
}
func main() {
data := TemplateData{
UserName: "azar-intelops",
ProjectName: "test",
}
projectRoot := "code"
templateDir := "templates/grpc"
for _, e := range utils.GetDirectoryList(templateDir) {
fmt.Println(utils.CheckIsDir(e.Name()))
}
if !utils.CheckDirectory(projectRoot, "./") {
if err := os.Mkdir(projectRoot, os.ModePerm); err != nil {
log.Fatal(err)
}
}
tmpl := template.Must(template.ParseFiles("templates/grpc/go.mod.tmpl"))
file, err := os.Create("./" + projectRoot + "/go.mod")
if err != nil {
panic(err)
}
defer file.Close()
err = tmpl.Execute(file, data)
if err != nil {
panic(err)
}
}