file

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Jul 17, 2020 License: Apache-2.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Basename

func Basename(fp string) string

返回路径的最后一个元素

func Close

func Close(fd *os.File) error

关闭文件

func Create

func Create(name string) (*os.File, error)

创建并打开文件

func Dir

func Dir(fp string) string

返回路径去掉最后一个元素后的剩余部分

func DirsUnder

func DirsUnder(dirPath string) ([]string, error)

目录下的所有目录

func Download

func Download(toFile, url string) error

下载文件

func EnsureDir

func EnsureDir(fp string) error

创建目录

func EnsureDirRW

func EnsureDirRW(dataDir string) error

确保目录存在并可写

func FileMTime

func FileMTime(fp string) (int64, error)

获取文件的mtime

func FileSize

func FileSize(fp string) (int64, error)

获取文件的大小

func FilesUnder

func FilesUnder(dirPath string) ([]string, error)

目录下的所有文件

func InsureDir

func InsureDir(fp string) error

判断目录是否存在,不存在则创建

func IsExist

func IsExist(fp string) bool

判断文件或目录是否存在

func IsFile

func IsFile(fp string) bool

是不是文件

func MD5

func MD5(file string) (string, error)

文件内容做md5

func OpenLogFile

func OpenLogFile(fp string) (*os.File, error)

打开文件,追加模式

func ReadBytes

func ReadBytes(cpath string) ([]byte, error)

读取文件内容,[]byte类型

func ReadJson

func ReadJson(cpath string, cptr interface{}) error

读取json文件

func ReadLineBytes

func ReadLineBytes(r *bufio.Reader) ([]byte, error)

读取一行

func ReadLineString

func ReadLineString(r *bufio.Reader) (string, error)

func ReadString

func ReadString(cpath string) (string, error)

读取文件内容,string类型

func ReadStringTrim

func ReadStringTrim(cpath string) (string, error)

读取文件内容,删除首尾的空白

func ReadYaml

func ReadYaml(cpath string, cptr interface{}) error

读取yaml文件

func RealPath

func RealPath(fp string) (string, error)

文件的绝对路径

func Remove

func Remove(name string) error

删除文件

func SelfDir

func SelfDir() string

获取文件所在目录的绝对路径

func SelfPath

func SelfPath() string

文件的绝对路径

func Unlink(fp string) error

取消软连接删除文件

func WriteBytes

func WriteBytes(filePath string, b []byte) (int, error)

将byte写入到文件

func WriteString

func WriteString(filePath string, s string) (int, error)

将string写入文件

Types

This section is empty.

Jump to

Keyboard shortcuts

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