-
Notifications
You must be signed in to change notification settings - Fork 0
/
template.go
58 lines (44 loc) · 842 Bytes
/
template.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
package main
import "fmt"
var tmplMainGo = []byte(`package main
import (
"fmt"
)
func main() {
fmt.Println("hello world")
}
`)
func GetBasicTmplMainGo() []byte {
return tmplMainGo
}
var tmplConfigYAML = []byte(`# auto-generated version field
version: v1.0
`)
func GetBasicTmplConfigYAML() []byte {
return tmplConfigYAML
}
var tmplConfigYAMLGo = []byte(`package config
import (
"fmt"
"github.com/spf13/viper"
"os"
)
var Cfg *viper.Viper
func init() {
defer func() {
if e := recover(); e != nil {
fmt.Println(e)
os.Exit(-1)
}
}()
var e error
Cfg = viper.New()
Cfg.SetConfigFile("%s")
if e = Cfg.ReadInConfig(); e != nil {
panic(e)
}
fmt.Println(Cfg.GetString("version"))
}`)
func GetBasicTmplConfigYAMLGO(filePath string) []byte {
return []byte(fmt.Sprintf(string(tmplConfigYAMLGo), filePath))
}