tio

package
v1.0.54 Latest Latest
Warning

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

Go to latest
Published: Apr 25, 2024 License: MIT Imports: 7 Imported by: 4

Documentation

Index

Constants

This section is empty.

Variables

View Source
var DefaultPermOpen = os.FileMode(0666)
View Source
var LineBreak = []byte{'\n'}

Functions

func ExistDir

func ExistDir(name string) (bool, error)

ExistDir 判断目录是否存在

func ExistFile

func ExistFile(name string) (bool, error)

ExistFile 判断文件是否存在

func FileSize

func FileSize(file *os.File) (int64, error)

FileSize 通过打开的文件计算大小(Byte单位)

func FileSizeByPath

func FileSizeByPath(path string) (int64, error)

FileSizeByPath 通过路径计算文件的大小(Byte单位)

func Mkdirs

func Mkdirs(path string, perms ...os.FileMode) error

Mkdirs 根据路径创建目录

func ReadDir

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

ReadDir 读取目录的内容,分别返回目录,文件的全路径集合

func ReadFile

func ReadFile(path string) ([]byte, error)

ReadFile 读取文件的内容

func ReadLine

func ReadLine(buffer *bufio.Reader) ([]byte, error)

ReadLine 按行读取文件内容 为了提升性能,使用前需将文件转换为buffer reader file, err := os.Open(path)

if err != nil {
     return err
}

defer file.Close() buffer := bufio.NewReader(file) ReadLine(buffer)

func ReadLines

func ReadLines(path string) ([][]byte, error)

ReadLines 读取文件内容,按行返回

func ScanStd

func ScanStd(handler LineHandler, hints ...string) error

ScanStd 从标准输入读取内容

func SplitFile

func SplitFile(path string) (string, string, error)

SplitFile 获取文件的目录和文件名

func WriteFile

func WriteFile(path string, content []byte, append bool) (int64, error)

WriteFile 将content的数据写入文件

Types

type LineHandler

type LineHandler func(string) error

Jump to

Keyboard shortcuts

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