-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.go
49 lines (36 loc) · 972 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
47
48
49
package internal
import (
"log"
"github.com/spf13/viper"
)
func GetConfig(key string) string {
viper.New()
viper.SetConfigName("pluto")
viper.AddConfigPath(".")
viper.SetConfigType("yaml")
var err error = viper.ReadInConfig()
if err != nil {
log.Fatal(err)
}
return viper.GetString(key)
}
func GetMySQlConfig() string {
var config string
config += GetConfig("mysql.username")
config += ":" + GetConfig("mysql.password")
config += "@tcp(" + GetConfig("mysql.host") + ":" + GetConfig("mysql.port") + ")"
config += "/" + GetConfig("mysql.database")
config += "?multiStatements=true"
return config
}
func GetPostgreConfig() string {
var config string
config += GetConfig("postgre.username")
config += ":" + GetConfig("postgre.password")
config += "@(" + GetConfig("postgre.host") + ":" + GetConfig("postgre.port") + ")"
config += "/" + GetConfig("postgre.database")
return config
}
func GetSource() string {
return GetConfig("source")
}