Untitled
unknown
plain_text
a year ago
619 B
1
Indexable
Never
func (d *WorkDir) ListFilesRoot() []string { list, _ := d.ListFilesIn("") for i, s := range list { list[i] = s[1:] } return list } func (d *WorkDir) ListFilesIn(path string) ([]string, error) { var files []string dirContents, err := os.ReadDir(d.root + "/" + path) if err != nil { return nil, err } for _, item := range dirContents { if item.IsDir() { subfiles, err := d.ListFilesIn(path + "/" + item.Name()) if err != nil { return nil, err } files = append(files, subfiles...) } else { files = append(files, path+"/"+item.Name()) } } return files, nil }