Skip to content

Instantly share code, notes, and snippets.

@klashxx
Last active September 18, 2019 12:36
Show Gist options
  • Save klashxx/0781f9b2e68e15e487d25b664e9aec96 to your computer and use it in GitHub Desktop.
Save klashxx/0781f9b2e68e15e487d25b664e9aec96 to your computer and use it in GitHub Desktop.

Revisions

  1. klashxx revised this gist Sep 18, 2019. 1 changed file with 0 additions and 3 deletions.
    3 changes: 0 additions & 3 deletions list_dirs.go
    Original file line number Diff line number Diff line change
    @@ -8,9 +8,6 @@ func listDirectories(path string) ([]string, error) {
    for _, item := range items {
    // We only want directories
    if item.IsDir() {
    if item.Name() == "testdata" {
    continue
    }
    currentDir := filepath.Join(path, item.Name())
    names = append(names, currentDir)

  2. klashxx created this gist Sep 18, 2019.
    26 changes: 26 additions & 0 deletions list_dirs.go
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,26 @@
    func listDirectories(path string) ([]string, error) {
    names := []string{}
    items, err := ioutil.ReadDir(path)
    if err != nil {
    return names, err
    }

    for _, item := range items {
    // We only want directories
    if item.IsDir() {
    if item.Name() == "testdata" {
    continue
    }
    currentDir := filepath.Join(path, item.Name())
    names = append(names, currentDir)

    // Do some recursion
    subNames, err := listDirectories(currentDir)
    if err == nil {
    names = append(names, subNames...)
    }
    }
    }

    return names, nil
    }