2019-06-07 09:55:03 +00:00
|
|
|
// 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 (
|
2023-07-19 01:11:09 +00:00
|
|
|
"os"
|
2019-06-07 09:55:03 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
// Dirs returns a slice of all the directories within a given directory
|
|
|
|
func Dirs(path string) []string {
|
2023-07-19 01:11:09 +00:00
|
|
|
files, err := os.ReadDir(path)
|
2019-06-07 09:55:03 +00:00
|
|
|
if err != nil {
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
|
|
|
var fnms []string
|
|
|
|
for _, fi := range files {
|
|
|
|
if fi.IsDir() {
|
|
|
|
fnms = append(fnms, fi.Name())
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return fnms
|
|
|
|
}
|