AssetDir returns the file names below a certain directory embedded in the file by go-bindata. For example if you run go-bindata on data/... and data contains the following hierarchy: data/ foo.txt img/ a.png b.png then AssetDir("data") would return []string{"foo.txt", "img"} Asset
(name string)
| 212 | // AssetDir("foo.txt") and AssetDir("notexist") would return an error |
| 213 | // AssetDir("") will return []string{"data"}. |
| 214 | func AssetDir(name string) ([]string, error) { |
| 215 | node := _bintree |
| 216 | if len(name) != 0 { |
| 217 | cannonicalName := strings.Replace(name, "\\", "/", -1) |
| 218 | pathList := strings.Split(cannonicalName, "/") |
| 219 | for _, p := range pathList { |
| 220 | node = node.Children[p] |
| 221 | if node == nil { |
| 222 | return nil, fmt.Errorf("Asset %s not found", name) |
| 223 | } |
| 224 | } |
| 225 | } |
| 226 | if node.Func != nil { |
| 227 | return nil, fmt.Errorf("Asset %s not found", name) |
| 228 | } |
| 229 | rv := make([]string, 0, len(node.Children)) |
| 230 | for childName := range node.Children { |
| 231 | rv = append(rv, childName) |
| 232 | } |
| 233 | return rv, nil |
| 234 | } |
| 235 | |
| 236 | type bintree struct { |
| 237 | Func func() (*asset, error) |