-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathcreateConfig.go
55 lines (48 loc) · 1.1 KB
/
createConfig.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
package main
import (
"fmt"
"io/ioutil"
"log"
"os"
helper "github.com/shouva/dailyhelper"
)
func createConfig() {
str := `package main
// Config :
type Config struct {
Database Database ` + "`" + `json:"database"` + "`" + `
}
// Database :
type Database struct {
Host string ` + "`" + `json:"host"` + "`" + `
Port string ` + "`" + `json:"port"` + "`" + `
User string ` + "`" + `json:"username"` + "`" + `
Password string ` + "`" + `json:"password"` + "`" + `
DBName string ` + "`" + `json:"dbname"` + "`" + `
}
`
filename := folder + "/config.go"
f, err := os.Create(filename)
defer f.Close()
if err != nil {
log.Println("create file: ", err)
return
}
f.Write([]byte(str))
completer(filename)
}
func copyConfig() {
sourceFile := helper.GetCurrentPath(false) + "/config.json"
destinationFile := folder + "/config.json"
input, err := ioutil.ReadFile(sourceFile)
if err != nil {
fmt.Println(err)
return
}
err = ioutil.WriteFile(destinationFile, input, 0644)
if err != nil {
fmt.Println("Error creating", destinationFile)
fmt.Println(err)
return
}
}