forked from manabie-com/togo
-
Notifications
You must be signed in to change notification settings - Fork 0
/
config.go
39 lines (34 loc) · 813 Bytes
/
config.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 config
import (
"fmt"
"io/ioutil"
"os"
"path/filepath"
"strings"
)
func Asset(name string) ([]byte, error) {
rootPath, err := os.Getwd()
if err != nil {
return nil, err
}
base := filepath.Join(rootPath, "core/config")
if strings.Contains(name, "..") {
panic(fmt.Sprintf("invalid name (%v)", name))
}
return ioutil.ReadFile(filepath.Join(base, name))
}
type DBConfig struct {
PostgresDB *PostgresConfig `json:"postgres_db"`
Test_PostgresDB *PostgresConfig `json:"test_postgres_db"`
}
type PostgresConfig struct {
Host string `json:"host"`
Port int `json:"port"`
Username string `json:"username"`
Password string `json:"password"`
Database string `json:"database"`
SSLMode string `json:"sslmode"`
}
type Config struct {
Databases DBConfig `json:"databases"`
}