Documentation
¶
Overview ¶
Author: Kernel.Huang Mail: kernelman79@gmail.com File: FileService Date: 3/21/21 12:50 AM
Index ¶
- Constants
- Variables
- type ArrayUtil
- func (a *ArrayUtil) EqIntSlice(source, target []int) bool
- func (a *ArrayUtil) EqStringSlice(source, target []string) bool
- func (a *ArrayUtil) ReverseRune(runes []rune) []rune
- func (a *ArrayUtil) ReverseStringArray(arr []string) []string
- func (a *ArrayUtil) StringArrayOffsetToString(arr []string, need string, offset int) string
- type FileServices
- func (file *FileServices) AddString(content string) bool
- func (file *FileServices) AddWrite(filename string) *FileServices
- func (file *FileServices) AppendWrite(filename string) *os.File
- func (file *FileServices) BufIoPut(filename string, content string) bool
- func (file *FileServices) CheckFileActive(filename string) int64
- func (file *FileServices) CloseFile() bool
- func (file *FileServices) Create(filename string) *os.File
- func (file *FileServices) CreateDir(path string, perm ...os.FileMode) bool
- func (file *FileServices) FileInfo(filename string) os.FileInfo
- func (file *FileServices) FromByte(content []byte) bool
- func (file *FileServices) FromString(str string) bool
- func (file *FileServices) GetFile(filename string) []byte
- func (file *FileServices) GetFileSize(filename string) int64
- func (file *FileServices) IoPut(filename string, content []byte) bool
- func (file *FileServices) IsExists(path string) error
- func (file *FileServices) MultiAddString(content string) bool
- func (file *FileServices) NewDir(path string, perm ...os.FileMode) bool
- func (file *FileServices) NewFolder(perm ...os.FileMode) bool
- func (file *FileServices) NewNonFolder(perm ...os.FileMode) bool
- func (file *FileServices) NewPath(path string) *FileServices
- func (file *FileServices) Overwrite(filename string) *os.File
- func (file *FileServices) PathExists(path string) bool
- func (file *FileServices) PutFile(filename string) *FileServices
- func (file *FileServices) RecursionIterateDir(path string, info os.FileInfo, node *fileNode, number *uint) error
- func (file *FileServices) ShowFileTree() *fileNode
- func (file *FileServices) Write(perm ...os.FileMode) *os.File
- type FormatServices
- func (format *FormatServices) Base64ToByte() []byte
- func (format *FormatServices) Base64ToString() string
- func (format *FormatServices) FromArrayString(from []string) *FormatServices
- func (format *FormatServices) FromBase64(from interface{}) *FormatServices
- func (format *FormatServices) FromBsonM(from interface{}) *FormatServices
- func (format *FormatServices) FromByte(from []byte) *FormatServices
- func (format *FormatServices) FromInt(from int) *FormatServices
- func (format *FormatServices) FromInt64(from int64) *FormatServices
- func (format *FormatServices) FromInterface(from interface{}) *FormatServices
- func (format *FormatServices) FromMapStringByte(from map[string][]byte) *FormatServices
- func (format *FormatServices) FromMapStringInterface(from map[string]interface{}) *FormatServices
- func (format *FormatServices) FromRune(from []rune) *FormatServices
- func (format *FormatServices) FromString(from string) *FormatServices
- func (format *FormatServices) InterfaceToArray() []string
- func (format *FormatServices) ToArrayArrayInt() [][]int
- func (format *FormatServices) ToArrayInt() []int
- func (format *FormatServices) ToArrayInterface() []interface{}
- func (format *FormatServices) ToArrayMapStringInterface() []map[string]interface{}
- func (format *FormatServices) ToArrayString() []string
- func (format *FormatServices) ToBase64() string
- func (format *FormatServices) ToBool() bool
- func (format *FormatServices) ToByte() []byte
- func (format *FormatServices) ToInt() int
- func (format *FormatServices) ToInt64() int64
- func (format *FormatServices) ToMapIntInterface() map[int]interface{}
- func (format *FormatServices) ToMapStringByte() map[string][]byte
- func (format *FormatServices) ToMapStringInterface() map[string]interface{}
- func (format *FormatServices) ToMapStringString() map[string]string
- func (format *FormatServices) ToRune() []rune
- func (format *FormatServices) ToString() string
- func (format *FormatServices) ToUint() uint
- type StrUtil
- func (s *StrUtil) Cull(str, need string) string
- func (s *StrUtil) IsNull(str ...string) bool
- func (s *StrUtil) Reverse(str string) string
- func (s *StrUtil) SplitGetBeforeSuffix(str string, need string, joinNeed string) string
- func (s *StrUtil) SplitGetPrefix(str string, need string) string
- func (s *StrUtil) SplitGetSuffix(str string, need string) string
- func (s *StrUtil) SplitLineBreak(path string) string
- func (s *StrUtil) SplitString(path string, need string) string
- func (s *StrUtil) Sub(source string, start int, end int) string
- func (s *StrUtil) SubLen(str string, pos int, length int) string
- func (s *StrUtil) ToLower(str string) string
- func (s *StrUtil) ToUpper(str string) string
- func (s *StrUtil) UcFirst(str string) string
Constants ¶
View Source
const DateFormat = "2006-01-02"
View Source
const MAX_ULIMIT = 65535
View Source
const MsTimeFormat = "2006-01-02 15:04:05.999"
View Source
const TimeFormat = "2006-01-02 15:04:05"
Variables ¶
View Source
var Array = new(ArrayUtil)
View Source
var Files = new(FileServices)
View Source
var Format = new(FormatServices)
View Source
var String = new(StrUtil)
View Source
var Time = new(times)
View Source
var UUID = new(uid)
Functions ¶
This section is empty.
Types ¶
type ArrayUtil ¶
type ArrayUtil struct{}
func (*ArrayUtil) EqIntSlice ¶
比较int切片是否相等
func (*ArrayUtil) EqStringSlice ¶
比较string切片是否相等
func (*ArrayUtil) ReverseStringArray ¶
反转[]string数组
type FileServices ¶
type FileServices struct {
Perm os.FileMode
DirPerm os.FileMode
// contains filtered or unexported fields
}
func (*FileServices) AddString ¶
func (file *FileServices) AddString(content string) bool
*
- 单次追加写入文本内容
- 示例: Files.AddWrite(filePath).AddString("text")
func (*FileServices) AddWrite ¶
func (file *FileServices) AddWrite(filename string) *FileServices
*
- 追加写入模式
func (*FileServices) AppendWrite ¶
func (file *FileServices) AppendWrite(filename string) *os.File
*
- 追加写入模式
- open := Files.AppendWrite(filePath)
- defer func() {_ = open.Close()}()
- write := bufio.NewWriter(open)
- _, _ := write.WriteString("text")
- _ = write.Flush()
func (*FileServices) BufIoPut ¶
func (file *FileServices) BufIoPut(filename string, content string) bool
*
- BufIO写入模式
func (*FileServices) CheckFileActive ¶
func (file *FileServices) CheckFileActive(filename string) int64
*
- 检查文件存活时间
func (*FileServices) CloseFile ¶
func (file *FileServices) CloseFile() bool
*
- 关闭文件句柄,使其无法用于I/O
- 示例:
- write := Files.AddWrite(filePath)
- write.MultiAddString("text")
- write.CloseFile()
func (*FileServices) Create ¶
func (file *FileServices) Create(filename string) *os.File
*
- 使用默认Perm:0666模式创建文件
func (*FileServices) CreateDir ¶
func (file *FileServices) CreateDir(path string, perm ...os.FileMode) bool
*
- 创建目录: path的所经过目录路径不存在则创建, 否则忽略
func (*FileServices) FromByte ¶
func (file *FileServices) FromByte(content []byte) bool
*
- []byte写入方式
- 示例: Files.PutFile(filePath).FromByte([]byte("text")
func (*FileServices) FromString ¶
func (file *FileServices) FromString(str string) bool
*
- 写入字符串内容
- 示例: Files.PutFile(filePath).FromString("text")
func (*FileServices) GetFileSize ¶
func (file *FileServices) GetFileSize(filename string) int64
*
- 获取文件大小
func (*FileServices) IoPut ¶
func (file *FileServices) IoPut(filename string, content []byte) bool
*
- []byte写入方式
func (*FileServices) IsExists ¶
func (file *FileServices) IsExists(path string) error
*
- 检查文件或目录是否存在,并返回错误
func (*FileServices) MultiAddString ¶
func (file *FileServices) MultiAddString(content string) bool
*
- 多次追加写入文本内容
- 示例:
- write := Files.AddWrite(filePath)
- write.MultiAddString("text1")
- write.MultiAddString("text2")
- write.CloseFile()
func (*FileServices) NewDir ¶
func (file *FileServices) NewDir(path string, perm ...os.FileMode) bool
*
- 新建一个目录
func (*FileServices) NewFolder ¶
func (file *FileServices) NewFolder(perm ...os.FileMode) bool
*
- 新建一个目录
func (*FileServices) NewNonFolder ¶
func (file *FileServices) NewNonFolder(perm ...os.FileMode) bool
*
- 新建目录: path的所经过目录路径不存在则创建, 否则忽略
func (*FileServices) Overwrite ¶
func (file *FileServices) Overwrite(filename string) *os.File
*
- 覆盖写入模式
- 示例:
- open := Files.AppendWrite(filePath)
- defer func() {_ = open.Close()}()
- write := bufio.NewWriter(open)
- _, _ := write.WriteString("text")
- _ = write.Flush()
func (*FileServices) PathExists ¶
func (file *FileServices) PathExists(path string) bool
*
- 检查文件或目录是否存在
func (*FileServices) PutFile ¶
func (file *FileServices) PutFile(filename string) *FileServices
func (*FileServices) RecursionIterateDir ¶
func (file *FileServices) RecursionIterateDir(path string, info os.FileInfo, node *fileNode, number *uint) error
*
- 递归遍历目录
type FormatServices ¶
type FormatServices struct {
From interface{}
To interface{}
}
func (*FormatServices) Base64ToByte ¶
func (format *FormatServices) Base64ToByte() []byte
func (*FormatServices) Base64ToString ¶
func (format *FormatServices) Base64ToString() string
func (*FormatServices) FromArrayString ¶
func (format *FormatServices) FromArrayString(from []string) *FormatServices
func (*FormatServices) FromBase64 ¶
func (format *FormatServices) FromBase64(from interface{}) *FormatServices
func (*FormatServices) FromBsonM ¶
func (format *FormatServices) FromBsonM(from interface{}) *FormatServices
func (*FormatServices) FromByte ¶
func (format *FormatServices) FromByte(from []byte) *FormatServices
func (*FormatServices) FromInt ¶
func (format *FormatServices) FromInt(from int) *FormatServices
func (*FormatServices) FromInt64 ¶
func (format *FormatServices) FromInt64(from int64) *FormatServices
func (*FormatServices) FromInterface ¶
func (format *FormatServices) FromInterface(from interface{}) *FormatServices
func (*FormatServices) FromMapStringByte ¶
func (format *FormatServices) FromMapStringByte(from map[string][]byte) *FormatServices
func (*FormatServices) FromMapStringInterface ¶
func (format *FormatServices) FromMapStringInterface(from map[string]interface{}) *FormatServices
func (*FormatServices) FromRune ¶
func (format *FormatServices) FromRune(from []rune) *FormatServices
func (*FormatServices) FromString ¶
func (format *FormatServices) FromString(from string) *FormatServices
func (*FormatServices) InterfaceToArray ¶
func (format *FormatServices) InterfaceToArray() []string
func (*FormatServices) ToArrayArrayInt ¶
func (format *FormatServices) ToArrayArrayInt() [][]int
func (*FormatServices) ToArrayInt ¶
func (format *FormatServices) ToArrayInt() []int
func (*FormatServices) ToArrayInterface ¶
func (format *FormatServices) ToArrayInterface() []interface{}
func (*FormatServices) ToArrayMapStringInterface ¶
func (format *FormatServices) ToArrayMapStringInterface() []map[string]interface{}
*
- 待测试
func (*FormatServices) ToArrayString ¶
func (format *FormatServices) ToArrayString() []string
func (*FormatServices) ToBase64 ¶
func (format *FormatServices) ToBase64() string
func (*FormatServices) ToBool ¶
func (format *FormatServices) ToBool() bool
func (*FormatServices) ToByte ¶
func (format *FormatServices) ToByte() []byte
func (*FormatServices) ToInt ¶
func (format *FormatServices) ToInt() int
func (*FormatServices) ToInt64 ¶
func (format *FormatServices) ToInt64() int64
func (*FormatServices) ToMapIntInterface ¶
func (format *FormatServices) ToMapIntInterface() map[int]interface{}
func (*FormatServices) ToMapStringByte ¶
func (format *FormatServices) ToMapStringByte() map[string][]byte
func (*FormatServices) ToMapStringInterface ¶
func (format *FormatServices) ToMapStringInterface() map[string]interface{}
func (*FormatServices) ToMapStringString ¶
func (format *FormatServices) ToMapStringString() map[string]string
func (*FormatServices) ToRune ¶
func (format *FormatServices) ToRune() []rune
func (*FormatServices) ToString ¶
func (format *FormatServices) ToString() string
func (*FormatServices) ToUint ¶
func (format *FormatServices) ToUint() uint
type StrUtil ¶
type StrUtil struct{}
func (*StrUtil) SplitGetBeforeSuffix ¶
分割字符串以获取字符串后缀之前的字符串
func (*StrUtil) SplitGetPrefix ¶
分割字符串以获取字符串前缀
func (*StrUtil) SplitGetSuffix ¶
分割字符串以获取字符串后缀
Click to show internal directories.
Click to hide internal directories.