Documentation ¶
Index ¶
- Constants
- Variables
- func CleanFile(path string) error
- func Copy(src, dst string) error
- func CopyAll(src, dst string) error
- func Create(v string) (*os.File, error)
- func CreateTemp(dir string, pattern string) (*os.File, error)
- func IsDir(path string) bool
- func IsExist(path string) bool
- func IsFile(path string) bool
- func Mkdir(path string, mode ...fs.FileMode) error
- func Move(src, dst string) error
- func Open(v string) (*os.File, error)
- func OpenFile(name string, flag int, perm fs.FileMode) (*os.File, error)
- func OpenRead(v string) ([]byte, error)
- func ReadAll(r io.Reader) ([]byte, error)
- func ReadDir(path string) []string
- func ReadDirAll(path string) []string
- func ReadDirInfo(path string) []fs.FileInfo
- func ReadDirRaw(path string) ([]fs.DirEntry, error)
- func ReaderWriter(w io.Reader, r io.Writer) (*bufio.Reader, *bufio.Writer)
- func Remove(v string) error
- func Rename(old, new string) error
- func Stat(w string) (os.FileInfo, error)
- func Symlink(src, dst string) error
- func TruncWrite(path string, d any) error
- func Write(path string, d any) error
Constants ¶
Variables ¶
Functions ¶
func CreateTemp ¶ added in v1.13.0
CreateTemp creates a new temporary file in the directory dir, opens the file for reading and writing, and returns the resulting file.
The filename is generated by taking pattern and adding a random string to the end.
If pattern includes a "*", the random string replaces the last "*".
If dir is the empty string, CreateTemp uses the default directory for temporary files, as returned by TempDir.
Multiple programs or goroutines calling CreateTemp simultaneously will not choose the same file.
The caller can use the file's Name method to find the pathname of the file.
It is the caller's responsibility to remove the file when it is no longer needed.
func IsDir ¶ added in v0.0.11
This function will check if the target is a directory.
**When the target does not exist or other errors occur, it will return `false`**
func Open ¶ added in v1.7.0
Open opens the named file for reading.
If successful, methods on the returned file can be used for reading; the associated file descriptor has mode O_RDONLY.
If there is an error, it will be of type *PathError.
func OpenFile ¶ added in v1.7.0
OpenFile is the generalized open call; most users will use Open or Create instead. It opens the named file with specified flag (O_RDONLY etc.). If the file does not exist, and the O_CREATE flag is passed, it is created with mode perm (before umask). If successful, methods on the returned File can be used for I/O. If there is an error, it will be of type *PathError.
func ReadAll ¶ added in v1.11.0
ReadAll reads from r until an error or EOF and returns the data it read. A successful call returns err == nil, not err == EOF. Because ReadAll is defined to read from src until EOF, it does not treat an EOF from Read as an error to be reported.
func ReadDirAll ¶ added in v1.5.0
func ReadDirInfo ¶ added in v1.17.0
func ReaderWriter ¶ added in v1.19.0
func TruncWrite ¶
Types ¶
This section is empty.