Documentation ¶
Index ¶
- func Create(filename string) (*os.File, error)
- func CreateOrAppend(filename string) (*os.File, error)
- func Exists(path string) (bool, error)
- func ForEachLine(path string, consume func(line string)) error
- func ForEachLineWithEncoding(path string, enc encoding.Encoding, consume func(line string)) error
- func IsDirectory(path string) (bool, error)
- func IsFile(path string) (bool, error)
- func MkDirs(path string) error
- func ReadAllBytes(path string) ([]byte, error)
- func ReadAllLines(path string) ([]string, error)
- func ReadAllLinesWithEncoding(path string, enc encoding.Encoding) ([]string, error)
- func ReadAllToString(path string) (string, error)
- func ReadAllToStringWithEncoding(path string, enc encoding.Encoding) (string, error)
- func WriteBytes(path string, data []byte) error
- func WriteString(path string, str string) error
- func WriteStringWithEncoding(path string, str string, enc encoding.Encoding) error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Create ¶
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 ¶
CreateOrAppend create a file for writing. This func creates along with any necessary parents directories, and append to file if file already exists.
func ForEachLine ¶
ForEachLine read line by line from a file, and return a error if read failed.
func ForEachLineWithEncoding ¶
ForEachLineWithEncoding read line by line from a file with specific, and return a error if read failed.
func IsDirectory ¶
IsDirectory return true if path is exists and is directory
func MkDirs ¶
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 ¶
ReadAllBytes read and return all data in file
func ReadAllLines ¶
ReadAllLines read all data from a file till EOF, return a lines slice.
func ReadAllLinesWithEncoding ¶
ReadAllLinesWithEncoding read all data from a file till EOF, return a lines slice.
func ReadAllToString ¶
ReadAllToString read and return all data as string in file
func ReadAllToStringWithEncoding ¶
ReadAllToStringWithEncoding read and return all data as string in file
func WriteBytes ¶
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 ¶
WriteString write all string content to file, and then close. If file already exists, will be overridden
Types ¶
This section is empty.