我正在寻找解封简单的yaml,但有些事情是不正确的。已经花了足够的时间了。需要帮忙吗?

package main

import (
    "fmt"

    yaml "gopkg.in/yaml.v2"
)

func main() {

    raw := `
targets:
  - from: "http://localhost:8080/test1"
    timeout: "10s"
  - from: "http://localhost:8080/test2"
    timeout: "30s"
`
    type Target struct {
        from    string `yaml:"from"`
        timeout string `yaml:"timeout"`
    }
    type config struct {
        Targets []Target `yaml:"targets"`
    }

    cfg := config{}

    err := yaml.Unmarshal([]byte(raw), &cfg)
    if err != nil {
        fmt.Println(err)
    }

    fmt.Println("Config", cfg)
}

我的订单空了

Config {[{ } { }]}

操场->https://play.golang.org/p/LANMpq_zPP9