MCPcopy Index your code
hub / github.com/devspace-sh/devspace / AssetDir

Function AssetDir

assets/assets.go:214–234  ·  view source on GitHub ↗

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)

Source from the content-addressed store, hash-verified

212// AssetDir("foo.txt") and AssetDir("notexist") would return an error
213// AssetDir("") will return []string{"data"}.
214func 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
236type bintree struct {
237 Func func() (*asset, error)

Callers 1

RestoreAssetsFunction · 0.85

Calls 1

ErrorfMethod · 0.45

Tested by

no test coverage detected