filex

package
v1.9.1 Latest Latest
Warning

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

Go to latest
Published: Oct 21, 2021 License: BSD-2-Clause Imports: 5 Imported by: 4

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CreateFile added in v1.8.4

func CreateFile(path string) (*os.File, error)

CreateFile create new file with mod 0o666 before umask, create parent dirs when needed. If the file already exists, it is truncated.

func Exists

func Exists(path string) (bool, error)

Exists check if file exists

func ForEachLine added in v1.2.0

func ForEachLine(path string, consume func(line string)) error

ForEachLine read line by line from a file, and return a error if read failed.

func ForEachLineWithEncoding added in v1.2.0

func ForEachLineWithEncoding(path string, enc encoding.Encoding, consume func(line string)) error

ForEachLineWithEncoding read line by line from a file with specific, and return a error if read failed.

func IsDirectory

func IsDirectory(path string) (bool, error)

IsDirectory return true if path is exists and is directory

func IsFile

func IsFile(path string) (bool, error)

IsFile return true if path is exists and is regular file

func MkDirs added in v1.8.4

func MkDirs(path string) error

MkDirs creates a directory named path, along with any necessary parents. The umask of dirs created is set to 0o777. Return err is any err occurred.If path is already a directory, MkdirAll does nothing and returns nil.

func ReadAllBytes added in v1.1.1

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

ReadAllBytes read and return all data in file

func ReadAllLines

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

ReadAllLines read all data from a file till EOF, return a lines slice.

func ReadAllLinesWithEncoding

func ReadAllLinesWithEncoding(path string, enc encoding.Encoding) ([]string, error)

ReadAllLinesWithEncoding read all data from a file till EOF, return a lines slice.

func ReadAllToString

func ReadAllToString(path string) (string, error)

ReadAllToString read and return all data as string in file

func ReadAllToStringWithEncoding

func ReadAllToStringWithEncoding(path string, enc encoding.Encoding) (string, error)

ReadAllToStringWithEncoding read and return all data as string in file

func WriteBytes added in v1.1.1

func WriteBytes(path string, data []byte) error

WriteBytes write all data to file, and then close. If file already exists, will be override

func WriteString

func WriteString(path string, str string) error

WriteString write all string content to file, and then close. If file already exists, will be override

func WriteStringWithEncoding

func WriteStringWithEncoding(path string, str string, enc encoding.Encoding) error

WriteStringWithEncoding write all string content to file using specific encoding, and then close. If file already exists, will be overridden

Types

This section is empty.

Jump to

Keyboard shortcuts

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