Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Not enough examples/documentation on usage #31

Open
gwuah opened this issue Sep 13, 2020 · 0 comments
Open

Not enough examples/documentation on usage #31

gwuah opened this issue Sep 13, 2020 · 0 comments

Comments

@gwuah
Copy link

gwuah commented Sep 13, 2020

First off, thanks for this tool.

I was trying to parse a simple yaml file like the one below and I couldn't find a helpful example.

- Ghana
- Mali
- Togo

I had to experiment several times before l I was able to parse it.
It would be nice if you added more examples. (I'm willing to contribute)

If anyone's interested in how I solved my problem 👇🏾

config, err := yaml.ReadFile("/database/seeds/countries.yml")

if err != nil {
	panic(err)
}

lst, ok := config.Root.(yaml.List)
if !ok {
	panic("failed to parse")
}

for i := 0; i < lst.Len(); i++ {
	item := lst.Item(i)
	fmt.Println(item)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant