Documentation ¶
Index ¶
- Constants
- func BaseDir(dirs []string) string
- func DirsUnder(dirPath string) ([]string, error)
- func DoesExists(filename string) bool
- func DoesNotExists(filename string) bool
- func ExistsAsDir(filename string) bool
- func ExistsAsFile(filename string) bool
- func HomeDirExpand(dir string) string
- func InsureDir(fp string) error
- func IsExist(fp string) bool
- func ReadBytes(filename string) []byte
- func ReadTime(filename string, defaultValue string) (time.Time, error)
- func ReadValue(filename, defaultValue string) (string, error)
- func SingleFileExists(name string) error
- func ToBytes(filePath string) ([]byte, error)
- func ToString(filePath string) (string, error)
- func ToTrimString(filePath string) (string, error)
- func WriteBytes(filePath string, b []byte) (int, error)
- func WriteString(filePath string, s string) (int, error)
- func WriteTime(filename string, v time.Time) error
- func WriteValue(filename string, value string) error
- type DirMode
- type ExistsEnum
Constants ¶
const (
// TimeFormat defines the format of time to save to the file.
TimeFormat = "2006-01-02 15:04:05.000"
)
Variables ¶
This section is empty.
Functions ¶
func DoesExists ¶
DoesExists checks if a file/directory exists.
func DoesNotExists ¶
DoesNotExists checks if a file/directory not exists.
func ExistsAsDir ¶
ExistsAsDir checks if a file exists and is a directory before we try using it to prevent further errors.
func ExistsAsFile ¶
ExistsAsFile checks if a file exists and is not a directory before we try using it to prevent further errors.
func HomeDirExpand ¶
HomeDirExpand expands the ~(home directory) from the dir.
func IsExist ¶
IsExist checks whether a file or directory exists. It returns false when the file or directory does not exist.
func ToTrimString ¶
ToTrimString reads the file to a trimmed string.
func WriteBytes ¶
WriteBytes writes byte slice to file.
func WriteString ¶
WriteString writes string to file.
func WriteValue ¶
WritValue writes a string value to the file.
Types ¶
type DirMode ¶
type DirMode int
DirMode means file is single file or directory.
func GetFileMode ¶
GetFileMode tells the name is a directory or not
type ExistsEnum ¶
type ExistsEnum int
ExistsEnum is the file exits enumeration.
const ( // Exists means the file exists. Exists ExistsEnum = iota // NotExists means the file not exists. NotExists // Unknown means unknown state. Unknown )