add node structure (cmd, config...)

This commit is contained in:
arnaucube
2019-12-07 17:27:30 +01:00
parent 5a4d536f0d
commit a3d1d8db78
11 changed files with 419 additions and 54 deletions

31
config/config.go Normal file
View File

@@ -0,0 +1,31 @@
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
}