maob_file

package
v0.0.0-...-8268eb9 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 2, 2021 License: Apache-2.0 Imports: 5 Imported by: 0

README

//@author: maob //@function: PathExists //@description: 获取目录下的所有目录名字,不包括文件 //@param: path string

//@author: maob //@function: PathExists //@description: 文件目录是否存在 //@param: path string //@return: bool, error // @test: ExamplePathExists()

//@author: maob //@function: CreateDir //@description: 批量创建文件夹 //@param: dirs ...string //@return: err error // test: TestCreateDir()

//@author: maob //@function: WriteStringWithEnter //@description: 自动换行插入数据,没有文件并且自动创建 //@return: error

//@author: maob //@function: ReadFileSplitEnter //@description: 读取文件,返回以换行符为分割的切片

Documentation

Index

Examples

Constants

This section is empty.

Variables

This section is empty.

Functions

func CreateDir

func CreateDir(dirs ...string) (err error)

func FileMove

func FileMove(src string, dst string) (err error)

func GetDirListNoRecursion

func GetDirListNoRecursion(path string) ([]string, error)

func PathExists

func PathExists(path string) (bool, error)
Example
var (
	readMe string
	exists bool
	err    error
)

// 存在文件形式
readMe = "./README.md"
if exists, err = PathExists(readMe); err != nil {
	return
}
fmt.Println(exists)
readMe = "./log/README.md"
if exists, err = PathExists(readMe); err != nil {
	return
}
fmt.Println(exists)

// 不存在文件,只是单纯的目录
readMe = "./"
if exists, err = PathExists(readMe); err != nil {
	return
}
fmt.Println(exists)
readMe = "./log"
if exists, err = PathExists(readMe); err != nil {
	return
}
fmt.Println(exists)

// 不存在的文件
readMe = "./l.log"
if exists, err = PathExists(readMe); err != nil {
	fmt.Println(err)
	return
}
fmt.Println(exists)
Output:

true
false
true
false
false

func ReadFileSplitEnter

func ReadFileSplitEnter(filePath string) ([]string, error)

func WriteStringWithEnter

func WriteStringWithEnter(dataStr, fp string) error

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL