go-bitbucket
go-bitbucket copied to clipboard
Question about repositories.ListForAccount()
Hello @ktrysmt ,
A question about repositories.ListForAccount() method. Is it normal that this method is returning an interface{} ? Note : I would expect to have a []string with repo names.
Maybe it is because this method is not finalized ? Any other reasons ?
In order to get the list of repo names, I did the following ugly code (just for testing). But maybe there is another smart way or magic method to get this ?
res2, err2 := c.Repositories.ListForTeam(opt2)
if err2 != nil {
panic(err2)
}
repos := show_repo(res2)
fmt.Printf("%#v\n", repos) // Just to debug content
func show_repo(data interface{}) []string {
var output []string // New slice
repos := data.(map[string]interface{})["values"].([]interface{})
// Loop on slice
for i := 0; i < len(repos); i++ {
output = append(output, repos[i].(map[string]interface{})["name"].(string))
}
return output
}
@uggla Perhaps this might be useful.
- https://godoc.org/github.com/jeremywohl/flatten
@ktrysmt thx. In fact the underlying question is will you accept PR that will change the behavior of these methods ? If yes we (@Xx-Parks-xX and I) will open a couple of PRs.
@uggla Basically PR is welcomed. If there are any points to worry about, we can discuss it at that time.