gopy/dirs.go

26 lines
493 B
Go

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