Documentation
¶
Overview ¶
OS Uiliities.
Index ¶
- Constants
- func FileAddSuffix(name string, ext string) string
- func FileChangeSuffix(name string, newSuffix string) (s string)
- func FileCutDotSuffix(name string) (s string, suffix string, ok bool)
- func FileCutSuffix(name string, ext string) (string, bool)
- func FileExists(path string) (bool, error)
- func FileHasAnySuffix(name string, ext ...string) bool
- func FileHasSuffix(name string, ext string) bool
- func FileReplaceSuffix(name string, ext string) string
- func MkdirAll(path string) error
- func MkdirParentAll(path string) error
- func MkdirTree(t DirTree) error
- func NewTmpFile() (*os.File, error)
- func NewTmpFilePath() (string, error)
- func NewTmpFilePathWith(suffix string) (string, error)
- func NewTmpFileWith(suffix string) (*os.File, error)
- func OpenAppendFile(name string) (*os.File, error)
- func OpenFile(name string, flag int) (*os.File, error)
- func OpenRFile(name string) (*os.File, error)
- func OpenRWFile(name string, createIfAbsent ...bool) (*os.File, error)
- func ReadFileAll(path string) ([]byte, error)
- func SaveTmpFile(tmpDir string, reader io.Reader) (string, error)
- func TryFileExists(path string) bool
- func WriteFile(name string, content []byte) error
- func WriteFileStr(name string, content string) error
- type DirTree
- type WalkFsFile
Constants ¶
Variables ¶
This section is empty.
Functions ¶
func FileAddSuffix ¶
func FileChangeSuffix ¶
func FileHasAnySuffix ¶
func FileHasSuffix ¶
func FileReplaceSuffix ¶
func MkdirParentAll ¶
MkdirAll but only for the parent directory of the path, perm 0755 is used.
The path should always point to a specific file under some directories, as this method always attempts to extract parent dir of the file. It the path fails to fulfill this requirement, the output might be unexpected.
func NewTmpFile ¶
func NewTmpFilePath ¶
func NewTmpFilePathWith ¶
func OpenAppendFile ¶
Create appendable file with 0666 permission.
func OpenRWFile ¶
Open readable & writable file with 0666 permission.
By default createIfAbsent is true.
func SaveTmpFile ¶
Save to temp file, returns temp file path or error.
func TryFileExists ¶
Check if file exists without returning error.
This is mainly a lazy version of FileExists(), it's not recommended for most cases.
func WriteFileStr ¶ added in v0.4.12
Create file and write content.
Types ¶
Click to show internal directories.
Click to hide internal directories.