Moved parameters to standalone fle
This commit is contained in:
27
params/params.go
Normal file
27
params/params.go
Normal file
@@ -0,0 +1,27 @@
|
||||
package params
|
||||
|
||||
import "github.com/spf13/viper"
|
||||
|
||||
type Config struct {
|
||||
TableName string `mapstructure:"TABLE_NAME"`
|
||||
AwsRegion string `mapstructure:"AWS_REGION"`
|
||||
TopNews string `mapstructure:"TOP_NEWS"`
|
||||
SingleNews string `mapstructure:"SINGLE_NEWS"`
|
||||
BatchSize int `mapstructure:"SERVER_ADDRESS"`
|
||||
}
|
||||
|
||||
func LoadConfig(path string) (config Config, err error) {
|
||||
viper.AddConfigPath(path)
|
||||
viper.SetConfigName("app")
|
||||
viper.SetConfigType("env")
|
||||
|
||||
viper.AutomaticEnv()
|
||||
|
||||
err = viper.ReadInConfig()
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
|
||||
err = viper.Unmarshal(&config)
|
||||
return
|
||||
}
|
||||
Reference in New Issue
Block a user