forked from arc1999/ExpenseGen
-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.go
39 lines (35 loc) · 742 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
package main
import (
"flag"
"fmt"
"html/template"
"log"
"os"
"github.com/gobuffalo/packr/v2"
)
type Json struct{
Struct string
}
// go:generate main -package="ExpenseGen" -Opname="Create" -Opname1="Update" -Opname2="Delete" -Opname3="GetbyId" -Opname4="GetAll"
func main() {
var struc string
flag.StringVar(&struc,"Structurename","","name of the structure")
flag.Parse()
box:= packr.New("temp","./templates")
t,err:=box.FindString("request-create.gotpl")
if err != nil {
log.Fatal(err)
}
tpl,err:= template.New("request").Parse(t)
if err != nil {
fmt.Println(err)
}
data :=Json{
Struct: struc,
}
file,err := os.Create("./request/request.go")
err= tpl.Execute(file,data)
if err != nil {
fmt.Println(err)
}
}