Skip to content

Instantly share code, notes, and snippets.

@afarid
Last active October 2, 2022 12:53
Show Gist options
  • Select an option

  • Save afarid/3011df59fe404d65532a719d119a65bc to your computer and use it in GitHub Desktop.

Select an option

Save afarid/3011df59fe404d65532a719d119a65bc to your computer and use it in GitHub Desktop.
root.go
type Todo struct {
Name string `mapstructure:"name"`
Description string `mapstructure:"description"`
Deadline string `mapstructure:"deadline"`
}
type Todos struct {
Todos []Todo `mapstructure:"todos"`
}
var todos Todos
func initConfig() {
.......
if err := viper.Unmarshal(&todos); err != nil {
fmt.Fprintln(os.Stderr, "Unable to Unmarshal config file", err)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment