-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathconfig.go
More file actions
42 lines (35 loc) · 748 Bytes
/
Copy pathconfig.go
File metadata and controls
42 lines (35 loc) · 748 Bytes
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
package main
import (
"log"
"github.com/spf13/viper"
)
type Configurations struct{
AuthToken string
Server ServerConfigurations
Database DatabaseConfigurations
}
type ServerConfigurations struct {
Port int
}
type DatabaseConfigurations struct {
DbName string
DbUser string
DbPassword string
DbPort int
DbBaseUrl string
}
var C Configurations
// loading configurations from conf.yaml file using viper
func loadConfigurations(){
viper.AddConfigPath(".")
viper.SetConfigName("conf")
viper.SetConfigType("yaml")
err := viper.ReadInConfig()
if err != nil {
log.Fatalf("Error reading config file, %s", err)
}
err = viper.Unmarshal(&C)
if err != nil {
log.Fatalf("Unable to decode into struct, %v", err)
}
}