如何将Yaml键映射到Golang中的结构?

I'm looking to write a go script that can parse through a yaml file. I created a test yaml file with the following:

    Dog:
      - name: "Dog"
      - secrets:
          username: "Shiba"
          password: "inu"
          color: "yellow"
    Cat:
      - name: "Cat"
      - secrets:
          words: "meow"
          color: "black"

What would the mapping to a struct look like in go?

I've tried along the lines of:

            package main

            import (
                "fmt"
                "log"

                "github.com/spf13/viper"
            )

            type Animal struct {
                Animal  []string
                Name    string
                Secrets []map[string]string
            }

            func main() {
                viper.SetConfigName("demo")
                viper.AddConfigPath(".")
                viper.SetConfigType("yaml")

                err := viper.ReadInConfig()

                if err != nil {
                    log.Fatal(err)
                }

                var animal Animal
                err = viper.Unmarshal(&animal)
                if err != nil {
                    log.Fatal(err)
                }

                fmt.Println(animal.Name)
            }

But nothing is returned

Any help would be much appreciated

Thanks

You should iterate over your uppermost yml keys ["Dog", "Cat"] and then put it into the struct. If you put this in your config it outputs the name of the animal:

name: "Dog"