Documentation
¶
Overview ¶
Index ¶
- Constants
- func CamelToSnake(s string) string
- func CamelToSnakeLine(s string) string
- func ContainsAll(s string, list []string) (isContains bool)
- func Copy(list []string, destPath string)
- func CopyOne(src string, dst string) error
- func CreateTree(rootPath string, file []string, isCreateFile bool) error
- func CurrentDir() string
- func Duplicate(slice []string) []string
- func FileName(filePath string, separator string) string
- func FilePath(filePath string, separator string) string
- func GetDataMap(db *sql.DB, sSql string) ([]map[string]interface{}, error)
- func HasSuffix(s string, f string) (has bool)
- func HyphenToCamelLine(s string, isUpFirst bool, convOther bool) string
- func InArray(s string, list []string) int
- func IsAllEmpty(list []string) (isEmpty bool)
- func IsExist(path string) bool
- func IsInArray(s string, list []string) (isIn bool)
- func IsInPrefix(s string, list []string) (isIn bool)
- func IsInSuffix(s string, list []string) (isIn bool)
- func IsPartInArray(s string, list []string) (isIn bool)
- func JsonArrayToMap(sJson string) (result []map[string]interface{}, err error)
- func JsonFileToMap(jsonFile string) (result interface{}, err error)
- func JsonToMap(sJson string) (result map[string]interface{}, err error)
- func LowerFirst(s string) string
- func Merge(srcFile []string, outFileName string)
- func Now(format string) string
- func OutFile(filename string, obj interface{}) error
- func OutTerminal(obj interface{})
- func ReadFile(filename string) (string, error)
- func RemoveEmpty(slice []string) []string
- func SearchByNamePartType(path []string, fileNamePart []string, fileType []string, ignorePath []string) []string
- func SearchByType(path []string, fileType []string, ignorePath []string) []string
- func SearchFile(option SearchOption) []string
- func SearchXlsx(path []string, ignorePath []string) []string
- func SnakeToCamel(s string, isUpFirst bool, convOther bool) string
- func SnakeToCamelLine(s string, isUpFirst bool, convOther bool) string
- func StringArrayToByte(sa []string) []byte
- func ToDecimal(value float64, c int) float64
- func UperFirst(s string) string
- func WriteFile(filename string, strarr []string) error
- type ExplorerOption
- type FileInfo
- type SearchOption
- type SearchResult
- type Stack
- type TreeNode
Constants ¶
const DATE_TIME_FOMART string = "2006-01-02 15:04:05"
const DATE_TIME_FOMART_SIMPLE string = "20060102150405"
const DATE_TIME_FOMART_YMD string = "2006/01/02"
const DATE_TIME_FOMART_YMD_SIMPLE string = "20060102"
const OS_DARWIN string = `darwin`
const OS_FREEBSD string = `freebsd`
const OS_LINUX string = `linux`
const OS_WINDOWS string = `windows`
const PATTERN_DEFAULT string = "0"
搜索模式(忽略模式)
0 : 默认 1 : 包含 2 : 相等 3 : 以开头 4 : 以结尾 5 : 正则表达式
const PATTERN_EQUAL string = "2"
const PATTERN_INCLUDE string = "1"
const PATTERN_PREFIX string = "3"
const PATTERN_REGEXP string = "5"
const PATTERN_SUFFIX string = "4"
const S_BACKLASH string = `\`
const S_BRACE_LEFT string = `{`
大括号
const S_BRACE_RIGHT string = `}`
const S_BRACKET_LEFT string = `[`
中括号
const S_BRACKET_RIGHT string = `]`
const S_COLON string = ":"
const S_COMMA string = ","
const S_DOT string = `.`
const S_DOUBLE_BACKLASH string = `\\`
const S_DOUBLE_QOTATION string = `"`
const S_EMPTY string = ""
const S_EMPTY_LINE string = `
`
const S_INDENT string = " "
const S_PARENTHESE_LEFT string = `(`
小括号
const S_PARENTHESE_RIGHT string = `)`
const S_QOTATION string = "'"
const S_SEMICOLON string = ";"
const S_SLASH string = `/`
const S_SPACE string = " "
const S_UNDERBAR string = "_"
const S_ZERO string = "0"
Variables ¶
This section is empty.
Functions ¶
func CurrentDir ¶
func CurrentDir() string
获取程序运行路径 参考:
https://blog.csdn.net/sufu1065/article/details/80116627
func GetDataMap ¶
SQL查询结果放到Map中 参考(引用):
https://www.cnblogs.com/mafeng/p/6207702.html https://stackoverflow.com/questions/19991541/dumping-mysql-tables-to-json-with-golang
func HyphenToCamelLine ¶
短线连接字符串转驼峰(首字母转大写)
无换行符
例:
test_id => TestId test_place_name => TestPlaceName
isUpFirst : true: 首字母转大写 false:首字母转小写 convOther : true: 非短线连接转换成小写 false: 非短线连接不转换
func IsExist ¶
引用: https://www.cnblogs.com/wangqishu/p/5147107.html 判断文件或目录是否存在
func JsonArrayToMap ¶
JSON(数组)字符串转换成Map
func JsonFileToMap ¶
JSON文件转换成Map
func Merge ¶
参考: https://www.golangtc.com/t/53749f5d320b521bba000007 多个文件合并成一个文件
func SearchByNamePartType ¶
func SearchByNamePartType(path []string, fileNamePart []string, fileType []string, ignorePath []string) []string
快捷搜索 以目标文件名关键字搜索多个目录下的指定文件类型, 返回文件全路径切片
path : 搜索目录 fileNamePart : 目标文件名关键字 fileType : 搜索文件类型 ignorePath : 忽略目录(设置此项有助于提高查找效率),例:[]string{".git", ".svn"}
func SearchByType ¶
快捷搜索 搜索多个目录下的指定文件类型, 返回文件全路径切片
path : 搜索目录 fileType : 搜索文件类型 ignorePath : 忽略目录(设置此项有助于提高查找效率),例:[]string{".git", ".svn"}
func SearchFile ¶
func SearchFile(option SearchOption) []string
搜索多个目录下的文件,返回文件全路径切片 添加参数判断
目标文件类型已指定, 忽略文件类型无须指定。后续处理中忽略文件类型作为空处理
result : 文件全路径切片 option : 搜索选项
func SearchXlsx ¶
快捷搜索XLSX(XLSM)文件
path : 搜索目录 ignorePath : 忽略目录(设置此项有助于提高查找效率),例:[]string{".git", ".svn"}
func SnakeToCamel ¶
下划线连接字符串转驼峰
含有换行符
isUpFirst : true: 首字母转大写 false:首字母转小写 convOther : true: 非下划线连接转换成小写 false: 非下划线连接不转换
func SnakeToCamelLine ¶
下划线连接字符串转驼峰(首字母转大写)
无换行符
例:
test_id => TestId test_place_name => TestPlaceName
isUpFirst : true: 首字母转大写 false:首字母转小写 convOther : true: 非下划线连接转换成小写 false: 非下划线连接不转换
Types ¶
type ExplorerOption ¶
type ExplorerOption struct { RootPath []string `yaml:"rootPath"` // 目标根目录 SearchSubPath bool `yaml:"searchSubPath"` // 搜索子目录 IgnorePath []string `yaml:"ignorePath"` // 忽略目录 IgnoreFile []string `yaml:"ignoreFile"` // 忽略文件 }
遍历选项
type FileInfo ¶
type FileInfo struct { File string `json:"file"` // 文件全路径 FileName string `json:"fileName"` // 文件名 FileType string `json:"fileType"` // 文件类型 Size int64 `json:"size"` // 文件大小 Mode os.FileMode `json:"mode"` // 文件模式 ModTime string `json:"modTime"` // 最终修改时间 }
文件信息(自定义FileInfo, 区别于os.FileInfo)
type SearchOption ¶
type SearchOption struct { RootPath []string `yaml:"rootPath"` // 目标根目录 SearchSubPath bool `yaml:"searchSubPath"` // 搜索子目录 MatchCase bool `yaml:"matchCase"` // 区分大小写 FileNamePart []string `yaml:"fileNamePart"` // 目标文件名关键字 FileType []string `yaml:"fileType"` // 目标文件类型 Pattern string `yaml:"pattern"` // 搜索模式 IgnorePath []string `yaml:"ignorePath"` // 忽略目录(目录名完全相同,设置此项有助于提高搜索效率,常用忽略目录: .git, .svn) IgnoreFileNamePart []string `yaml:"ignoreFileNamePart"` // 忽略文件名关键字 IgnoreType []string `yaml:"ignoreType"` // 忽略文件类型 IgnorePattern string `yaml:"ignorePattern"` // 忽略模式 ShowDetail bool `yaml:"showDetail"` // 是否显示文件详细信息标志 }
搜索选项
type SearchResult ¶
type SearchResult struct { File []string `json:"file"` // 文件全路径 FileInfo []FileInfo `json:"fileInfo"` // 文件信息 Count int `json:"count"` // 文件总数 ErrInfo []string `json:"errInfo"` // 错误信息 ExInfo []string `json:"exInfo"` // 其它信息 }
搜索结果
func Search ¶
func Search(option SearchOption) (result SearchResult)
搜索多个目录下的文件 添加参数判断
目标文件类型已指定, 忽略文件类型无须指定。后续处理中忽略文件类型作为空处理
result : 搜索结果 option : 搜索选项