filex

package
v2.5.0 Latest Latest
Warning

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

Go to latest
Published: Jul 16, 2022 License: BSD-2-Clause Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Create

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

Create creates a file for writing. This func creates along with any necessary parents directories, and truncate the file if file already exists.

func CreateOrAppend

func CreateOrAppend(filename string) (*os.File, error)

CreateOrAppend create a file for writing. This func creates along with any necessary parents directories, and append to file if file already exists.

func Exists

func Exists(path string) (bool, error)

Exists check if file exists

func ForEachLine

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

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

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

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

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

WriteBytes write all data to file, and then close. If file already exists, will be overridden. This func creates along with any necessary parents directories

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 overridden

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