This repository has been archived on 2026-01-31. You can view files and clone it. You cannot open issues or pull requests or push a commit.
Files
hackernews-lambda-on-aws/params/params.go
2022-07-16 11:31:09 +02:00

29 lines
635 B
Go

package params
import "github.com/spf13/viper"
type Config struct {
TableName string `mapstructure:"TABLE_NAME"`
TableIndex string `mapstructure:"GLOBAL_SECONDARY_INDEX"`
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
}