-
Notifications
You must be signed in to change notification settings - Fork 0
/
appConfig.go
50 lines (40 loc) · 1 KB
/
appConfig.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
package config
import "os"
//AppConfig is an interface for application configuration
type AppConfig interface {
GetDatabaseHost() string
GetDatabaseName() string
GetDatabaseUser() string
GetDatabasePassword() string
}
type appConfig struct {
databaseHost string
databaseName string
databaseUser string
databasePassword string
httpPort string
}
//New is constructor for application config
func New() AppConfig {
config := new(appConfig)
config.load()
return config
}
func (c *appConfig) load() {
c.databaseHost = os.Getenv("APP_DATABASE_HOST")
c.databaseName = os.Getenv("POSTGRES_DB")
c.databaseUser = os.Getenv("POSTGRES_USER")
c.databasePassword = os.Getenv("POSTGRES_PASSWORD")
}
func (c *appConfig) GetDatabaseHost() string {
return c.databaseHost
}
func (c *appConfig) GetDatabaseName() string {
return c.databaseName
}
func (c *appConfig) GetDatabaseUser() string {
return c.databaseUser
}
func (c *appConfig) GetDatabasePassword() string {
return c.databasePassword
}