GoFrame gfile-类型判断
类型判断
IsDir
func IsDir(path string) bool
func ExampleIsDir() {
// init
var (
path = gfile.TempDir("gfile_example_basic_dir")
filePath = gfile.Join(gfile.TempDir("gfile_example_basic_dir"), "file1")
)
// Checks whether given `path` a directory.
fmt.Println(gfile.IsDir(path))
fmt.Println(gfile.IsDir(filePath))
// Output:
// true
// false
}
IsFile
func IsFile(path string) bool
func ExampleIsFile() {
// init
var (
filePath = gfile.Join(gfile.TempDir("gfile_example_basic_dir"), "file1")
dirPath = gfile.TempDir("gfile_example_basic_dir")
)
// Checks whether given `path` a file, which means it's not a directory.
fmt.Println(gfile.IsFile(filePath))
fmt.Println(gfile.IsFile(dirPath))
// Output:
// true
// false
}