You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 

31 lines
494 B

package config
import (
"github.com/spf13/viper"
"github.com/urfave/cli"
)
type Config struct {
ID string
Port string
}
var C Config
func MustRead(c *cli.Context) error {
viper.SetConfigType("yaml")
viper.SetConfigName("config")
viper.AddConfigPath(".")
if c.GlobalString("config") != "" {
viper.SetConfigFile(c.GlobalString("config"))
}
if err := viper.ReadInConfig(); err != nil {
return err
}
if err := viper.Unmarshal(&C); err != nil {
return err
}
return nil
}