У меня возникла проблема при попытке чтения в этом yaml с использованием gopkg.in / yaml.v2 Ошибка:
line 1: cannot unmarshal !!seq into main.Owners
Чтение файла :
content, _ := ioutil.ReadFile("apartments.yml")
owners := Owners{}
err := yaml.Unmarshal(content, &owners)
if err != nil {
fmt.Printf("%s\n", err)
}
Моя структура выглядит так:
type Owners struct {
Owner []struct {
Apartment string `yaml:"apartment"`
PaymentIds []string `yaml:"paymentIds"`
} `yaml:"owner"`
}
Данные:
- owner:
apartment: 002
paymentIds:
- KB002
- owner:
apartment: 003
paymentIds:
- KB003
- owner:
apartment: 004
paymentIds:
- KB004
- owner:
apartment: 005
paymentIds:
- KB005