gopy/dirs.go

26 lines
504 B
Go
Raw Normal View History

// Copyright 2015 The go-python Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
package main
import (
"io/ioutil"
)
// Dirs returns a slice of all the directories within a given directory
func Dirs(path string) []string {
files, err := ioutil.ReadDir(path)
if err != nil {
return nil
}
var fnms []string
for _, fi := range files {
if fi.IsDir() {
fnms = append(fnms, fi.Name())
}
}
return fnms
}