gutil

package module
v0.0.0-...-7336b8c Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 12, 2024 License: MIT Imports: 38 Imported by: 0

README

gutil

go 公共类
golang.org/x/crypto 无法下载,可以在下面地中获取所需要的crypto包.并存放到对应的golang.org文件夹的x目录下
https://github.com/swgloomy/crypto.git

文档

提供common基础类库
    asyncThreadProcess.go 提供异步线程处理类,待完善
const.go
1.WithNanos 时间格式化字符串 2006-01-02 15:04:05
fileProcess.go
1. CreateFileProcess
    文件夹创建方法 接收参数文件夹路径  返回错误对象
    根据文件夹路径创建文件,如文件存在则不做任何操作
    
2. PathExists
    判断文件或文件夹是否存在 接收参数文件或文件夹路径 返回是否存在及错误对象 true表示存在

3. FileCreateAndWrite
    写文件
    输入参数:文件内容 写入文件的路劲(包含文件名) 是否追加写入
    输出参数:错误对象
    
4. ReadFileByLine
    文件读取逐行进行读取
    输入参数: 文件路劲
    输出参数: 字符串数组(数组每一项对应文件的每一行) 错误对象
    
5. FileOpen
    文件打开
    输入参数:文件路径 是否追加
    输出参数:文件对象 错误对象
    
6. RWFileByWhere
    根据条件读写文件
    输入参数:文件路径 文件写入对象 条件平判断方法
    输出参数:错误对象
    
7. ReadFileLineNumber
    读取文件行数
        文件路径
        输出行数与错误对象
        
8. GetMyFileName
    获取文件名称及后缀名 未防止文件无后缀名,固这里返回值为数组对象
        输入参数: 文件路劲或文件名称
        输出参数: 文件名 文件后缀名 数组 第一项为文件名称 第二项为文件后缀名

9. GetMyAllFileByDir
    根据文件夹路径获取文件夹下所有文件
    输入参数: 文件夹路径
    输出参数: 文件名列表 错误对象
    
10. GetMyAllDirByDir
    根据文件夹路径获取文件夹下所有文件夹
    输入参数:文件夹路径
    输出参数:文件夹列表 错误对象
mysqlDB.go
1. MySqlDBStruct
    数据库连接对象
    type MySqlDBStruct struct {
    	DbUser string //数据库用户名
    	DbHost string //数据库地址
    	DbPort int    //数据库端口
    	DbPass string //数据库密码
    	DbName string //数据库库名
        MaxOpenConns int    // 用于设置最大打开的连接数,默认值为0表示不限制
        MaxIdleConns int    // 用于设置闲置的连接数
    }

2. MySqlSQlConntion
    数据库连接
    输入参数:数据库对象
    输出对象:数据库连接对象
    
3. MySqlClose
    数据库关闭
    输入参数:数据库连接对象
    
4. MySqlSelect
    查询方法
    输入参数: dbs数据库连接对象 model数据库对象 sqlStr 要执行的sql语句 param执行SQL的语句参数化传递
    输出参数: 查询返回条数  错误对象输出
    
5. MySqlSqlExec
    数据库运行方法
    输入参数: dbs数据库连接对象 model数据库对象 sqlStr 要执行的sql语句  param执行SQL的语句参数化传递
    输出参数: 执行结果对象  错误对象输出
    
6. MysqlSelectUnknowColumn
    查询所有字段值
    字段名称 字段值数组 错误对象
servicePIDProcess.go
const ProgramServicePIDPath = "./programRunPID.pid" // PID文件生成路径
当下列方法接收到的传入参数为空时,将使用默认的PID文件路径

1. WritePid
    写PID文件
    输入参数:文件路径
    
2. CheckPid
    检查pid文件是否存在,pid文件中的进程是否存在
    输入参数:pid文件路径
    输出参数:bool类型(true: 文件不存在或者进程不存在 false: 进程已存在)
    
3. RmPidFile
    删除PID文件
    输入参数:pid文件路径
dateProcess.go
1.DateFormat
    时间格式化处理
    输入参数:需要格式化的时间 格式化方式 示例yyyy-MM-dd hh:mm:ss.tttttt   2017-03-22 10:21:55.379415
redisHelp.go
1. OpenRedis
    redis通道开启
    addr IP地址+端口     idx 仓库数  
    
2. CloseRedis
    redis通道关闭
    
3. SetRedisCache
    设置redis缓存
    key 存储键名    value 存储值    cacheBssSeconds 存储时间(单位秒)
    
4. GetRedisCache
    获取redis缓存
    key 存储键名
decryptionProcess.go
1. AesEncrypt
    字符串加密
    输入参数: 需要加密的字符串
    输出参数: 加密后字符串 错误对象
    
2. AesDecrypt
    字符串解密
    输入参数: 需要解密的字符串  解密后字符串长度
    输出参数: 解密后字符串  错误对象
gpDB.go
// GP数据库连接对象
// create by gloomy 2017-3-30 15:27:26
type GpDBStruct struct {
	DbUser string //数据库用户名
	DbHost string //数据库地址
	DbPort int    //数据库端口
	DbPass string //数据库密码
	DbName string //数据库库名
    MaxOpenConns int    // 用于设置最大打开的连接数,默认值为0表示不限制
    MaxIdleConns int    // 用于设置闲置的连接数
}

其余同mysql类

提供方法:
    GpSqlConntion GP数据库连接
    GpSqlClose GP数据库关闭
    GpSqlSelect 查询方法
    GpSqlExec 数据库运行方法
    GPSelectUnknowColumn 查询所有字段值
mathProcess.go
1. Rounding
    四舍五入取舍
    
2. RoundingByInt
    四舍五入取舍
    除数 被除数 取舍几位
    
3. RoundingPercentageByInt
    四舍五入取舍 百分比
    除数 被除数 取舍几位
    
4. MustCompileMatch
    匹配字符串是否包含
    输入参数:
        matchStr 匹配字符串(例: match*  则匹配任何match开头的. *为全匹配)
        str 被匹配字符串
ftpHelpProcess.go
FTP帮助类实体
type FtpHelpStruct struct {
	IpAddr string // ip 地址
	Port int // 端口
	TimeOut time.Duration // 超时时间
	UserName string // 用户名
	PassWord string // 密码
	FilePaths string // 目标服务器路径
}

1. FtpFileStor
     FTP文件传输        
     FTP配置实体 文件内容 创建目标服务器的文件名
     错误对象
     
2. FtpRemoveFile
     FTP文件删除
     文件名 ftp配置对象
     错误对象
     
3. FtpRenameFile
    ftp修正远程服务器文件名称
    源文件 修正后的文件名称 ftp配置对象
    错误对象
fileDataRecording.go
 切块文件写入,防止文件过大 (编写缘由用于文件load进入数据库)
 文件数据记录对象
type FileDataRecording struct {
	sync.Mutex                         // 锁
	F                         *os.File // 文件对象
	FilePre                   string   // 文件开头字符串
	Fn                        string   // 文件路径
	Bytes                     int      // 文件大小
	Seq                       int      // 第几个
	FileProgram               string   // 文件存放路径
	MaxFileDataRecordingBytes int      // 文件大小
}

const maxFileDataRecordingBytes = 1000000 // 默认文件大小

1. OpenLoadFile
     打开文件数据记录
     文件存放目录地址 文件开头字符串 文件大小
     文件数据对象
    
2. Exit
     文件退出
    
3. Close
    文件关闭
    
4. Rotate
    文件切换
    
5. CreateNewFile
    创建新文件
    错误对象
    
6. WriteData
    写入数据
    需要写入的数据
    错误对象
    
7. FileList
    获取所有完成的文件列表
    文件列表
    
8. RemoveOldFileList
    删除过期文件
    几天前
excelUtil.go
1. ReadExcel
   excel数据获取
   sheet名称 数据内容 错误对象
   
2. ExcelSave
   excel保存
sftpUtil.go
// sftp配置
type SftpConfigStruct struct {
	Account      string // 登录用户名
	Password     string // 登录密码
	Port         int    // 服务器端口
	ConntionSize int    // MaxPacket sets the maximum size of the payload
	Addr         string // 连接地址
}

1. SftpClose 
    sftp 关闭
    
2. SftpReadDir
    sftp读取文件夹内容
XML帮助类
1.XmlContentReplace
    生成xml文件修正xml节点内容
watchFileUtil.go
如文件上传完成,统一使用文件修改回调方法.watchFile方法会保证文件上传完毕进行回调
1.WatchFile
    文件夹监控方法
        监控文件夹路径
        匹配字段(例: match*  则匹配任何match开头的. *为全匹配)
        删除文件回调方法
        文件修改回调方法
        文件改名回调方法
        文件创建回调方法
fileSendUtil.go
http文件上传
1.HttpSendFile
    文件发送处理方法
        发送http地址
        文件路径
        文件存放变量名
zipUtil.go
1. UnZip
   压缩包解压 (方法暂时遗弃,解压会出现数据丢失)
   输入参数:
    zipPathStr 压缩包路径
    dirPathStr 压缩包解压后路径
   输出参数:
    解压后存放文件的文件夹路径  错误对象
    
2. UnGzip
    gz压缩包解压 (暂时可能不支持压缩包内有多个文件的情况.未做测试)
    输入参数:
        zipPathStr 压缩包地址
        filePathStr 压缩包解压后文件路径
    输出参数:
        错误对象
fileDownLoad.go
1. HttpGetDownFile
    文件下载
    输入参数:
        urlPathStr url请求路径
        saveFilePath 下载文件保存路径
    输出参数:
        错误对象
arrayUtil.go
1. UniqueSlice
    字符串数组去重
    输入参数:
        数组指针
ginUtil.go

因gin更新,该方法暂停使用

1.GinInit
    gin初始化
    输入参数:
        debug 是否为调试模式
        serverListeningPort gin监听端口
        setGinRouter 设置gin路由方法.传入参数*gin.Engine及服务运行所需要的二级目录名称(如:程序运行使用http://www.baidu.com/map  其中map为二级目录名称)
    输出参数:
        *gin.Engine
logUtil.go
1. LogInit
  日志初始化
  当程序停止前需将glog进行关闭 调用glog.Close方法
  输入参数:
    debug 是否为调试模式,如果为调试模式,则在控制台进行日志输出,否则输出到日志文件中
    logsDir 日志存放目录
captcha
增加golang验证码图片生成方法,修正自https://github.com/dchest/captcha 
删除内部自验证.
New 方法返回验证码
WriteImage 输出验证码图片,通过http方式
WriteAudio 输出音频,通过http方式
emailUtil.go
增加邮件发送类
1.SendEmail
    输入参数
        用户邮箱地址
        用户密码
        smtp服务器地址
        发送端口
        邮件标题
        邮件内容
        收件人邮箱集合
        邮件类型(默认为:text/plain) 可以采用text/html的方式,这样可以在邮件内容中画表格html页面等(ps:别画的太前卫^_^)
cmdUtil.go
windows cmd命令
1. ExecCommand
    输入参数: 需要执行的命令
    输出参数:
        命令行回馈字符串
        错误对象
pictureUtil.go
base64图片转图片文件
1.PictureBase64ToFile
    输入参数:
        图片base64字符串
        路径(为空则默认在运行目录下创建文件)
    输出参数:
        图片路径
        错误对象     
cpuUtil.go
设置CPU核心使用数
1.SetCPUUseNumber
    输入参数:
        CPU核心数量(如果超出当前CPU核心数量则使用当前CPU最大核心数.参数为0时则使用最大核心数量)

Documentation

Overview

数组操作类 create by gloomy 2017-08-31 00:10:08

* 异步线程处理类 创建人:邵炜 创建时间:2017年3月13日14:34:27

* 时间处理类 创建人:邵炜 创建时间:2017年03月21日20:53:46

* AES加解密类库 create by gloomy 2017-03-29 23:32:31

email 类库 create by gloomy 2017-04-12 11:16:21

excel操作类 create by gloomy 2017-4-18 09:14:26

文件数据记录类 create by gloomy 2017-04-06 10:11:35

文件下载类 create by gloomy 2017-08-28 13:12:12

* 公共组件库 文件处理 创建人:邵炜 创建时间:2017年2月8日18:11:29

文件HTTP传输方法

FTP工具类 create by gloomy 2017-4-1 17:32:06

gin公共类 create by gloomy 2017-09-01 01:11:28

* gp数据库连接 create by gloomy 2017-3-30 15:24:11

* 随机数处理 create by gloomy 2017-03-29 22:11:23

* mySql数据库组件类 创建人:邵炜 创建时间:2017年03月11日15:55:14

* redis帮助类 create by gloomysw 2017-3-24 14:11:284

* 程序运行pid目录处理类 创建人:邵炜 创建时间:2017年03月11日11:03:55

sftp帮助类 create by gloomy 2017-05-09 20:19:24

增加map转换XML

* 公共组件库 构建三元运算 创建人:邵炜 创建时间:2017年2月8日18:50:51

文件监控类 create by gloomy 2017-5-3 11:40:32

压缩包解压 create by gloomy 2017-08-27 14:18:42

Index

Constants

View Source
const (
	WithNanos           = "2006-01-02 15:04:05" // 时间格式化字符串
	Result_Success_Code = "00000"               // 接口返回成功
)
View Source
const ProgramServicePIDPath = "./programRunPID.pid" // PID文件生成路径

Variables

View Source
var (
	AutoMatedTaskLock sync.RWMutex
	AutoMatedTaskFile map[string]int = make(map[string]int)
)
View Source
var ReplaceXmlStrArray map[string]string = make(map[string]string)

Functions

func AesDecrypt

func AesDecrypt(crypted string, aESKEY []byte) (string, error)

* 字符串解密 创建人:邵炜 创建时间:2016年3月18日09:56:20 输入参数: 需要解密的字符串 解密后字符串长度 输出参数: 解密后字符串 错误对象

func AesEncrypt

func AesEncrypt(origData string, aESKEY []byte) (string, error)

* 字符串加密 创建人:邵炜 创建时间:2016年3月18日09:50:36 输入参数: 需要加密的字符串 输出参数: 加密后字符串 错误对象

func AppendFileOpen

func AppendFileOpen(fileName string) (*os.File, error)

* 文件打开 创建人:邵炜 创建时间:2017年3月14日14:54:08 输入参数:文件路径 输出参数:文件对象 错误对象

func CheckPid

func CheckPid(pidFileStr string) bool

* 检查pid文件是否存在,pid文件中的进程是否存在 创建人:邵炜 创建时间:2017年03月11日15:36:21 输入参数:pid文件路径 输出参数:bool类型(true: 文件不存在或者进程不存在 false: 进程已存在)

func CloseRedis

func CloseRedis()

redis通道关闭 create by gloomysw 2017-3-24 14:20:10

func CreateFileProcess

func CreateFileProcess(path string) error

* 根据文件夹路径创建文件,如文件存在则不做任何操作 创建人:邵炜 创建时间:2016年12月21日17:23:54 输入参数:文件夹路径 输出参数:错误对象

func DateFormat

func DateFormat(timeDate time.Time, layerout string) string

* 时间格式化处理 创建人:邵炜 创建时间:2017年3月22日09:13:01 输入参数:需要格式化的时间 格式化方式 示例yyyy-MM-dd hh:mm:ss.tttttt 2017-03-22 10:21:55.379415

func ExcelSave

func ExcelSave(saveContent *map[string][][]string, saveFilePath string) error

excel保存 create by gloomy 2017-4-18 09:44:39

func ExecCommand

func ExecCommand(commandContent string) (*[]string, error)

执行函数命令 commandContent 需要执行的命令 create by gloomy 2018-2-25 16:41:52

func FileCreateAndWrite

func FileCreateAndWrite(content *[]byte, fileName string, isAppend bool) error

* 写文件 创建人:邵炜 创建时间:2016年9月7日16:31:39 输入参数:文件内容 写入文件的路劲(包含文件名) 是否追加写入 输出参数:错误对象

func FileOpen

func FileOpen(fileName string) (*os.File, error)

* 文件打开 创建人:邵炜 创建时间:2017年3月14日14:54:08 输入参数:文件路径 输出参数:文件对象 错误对象

func FileTransferProtocol

func FileTransferProtocol()

断点续传 create by gloomy 2017-08-29 16:14:01

func FtpExit

func FtpExit(ftpConntion *ftp.ServerConn)

ftp退出 create by gloomy 2017-4-14 11:25:04

func FtpFileStor

func FtpFileStor(model *FtpHelpStruct, ftpConntion *ftp.ServerConn, contentByte *[]byte, createFilePath string) error

FTP文件传输 create by gloomy 2017-4-1 17:36:11 FTP配置实体 文件内容 创建目标服务器的文件名 错误对象

func FtpNameList

func FtpNameList(pathStr string, ftpConntion *ftp.ServerConn, model *FtpHelpStruct) ([]string, error)

获取FTP上所有的文件列表 create by gloomy 2017-04-12 10:43:25 目录地址 文件列表集 错误对象

func FtpRemoveFile

func FtpRemoveFile(filePathStr string, ftpConntion *ftp.ServerConn, model *FtpHelpStruct) error

FTP文件删除 create by gloomy 2017-04-02 01:08:15 文件名 ftp配置对象 错误对象

func FtpRenameFile

func FtpRenameFile(from, to string, ftpConntion *ftp.ServerConn, model *FtpHelpStruct) error

ftp修正远程服务器文件名称 create by gloomy 2017-04-04 21:26:48 源文件 修正后的文件名称 ftp配置对象 错误对象

func GPSelectUnknowColumn

func GPSelectUnknowColumn(dbs *sql.DB, model GpDBStruct, sqlStr string, param ...interface{}) (*[]string, *[][]string, error)

查询所有字段值 create by gloomy 2017-5-12 16:38:58

func GetMyAllDirByDir

func GetMyAllDirByDir(pathStr string) (*[]string, error)

根据文件夹路径获取文件夹下所有文件夹 create by gloomy 2018-2-25 16:08:50

func GetMyAllFileByDir

func GetMyAllFileByDir(pathStr string) (*[]string, error)

根据文件夹路径获取文件夹下所有文件 create by gloomy 2017-08-27 14:12:49

func GetMyFileName

func GetMyFileName(filePaths string) *[]string

* 获取文件名称及后缀名 未防止文件无后缀名,固这里返回值为数组对象 创建人:邵炜 创建时间:2016年9月7日16:40:14 输入参数: 文件路劲或文件名称 输出参数: 文件名 文件后缀名 数组 第一项为文件名称 第二项为文件后缀名

func GetRedisCache

func GetRedisCache(key string) (string, error)

获取redis缓存 create by gloomysw 2017-3-24 14:29:16 key 存储键名

func GpSqlClose

func GpSqlClose(db *sql.DB)

GP数据库关闭 create by gloomy 2017-3-30 15:39:10

func GpSqlConntion

func GpSqlConntion(model GpDBStruct) (*sql.DB, error)

GP数据库连接 create by gloomy 2017-3-30 15:29:12

func GpSqlExec

func GpSqlExec(dbs *sql.DB, model GpDBStruct, sqlStr string, param ...interface{}) (sql.Result, error)

* 数据库运行方法 创建人:邵炜 创建时间:2015年12月29日17:33:06 修正时间:2017年03月11日16:21:36 输入参数: dbs数据库连接对象 model数据库对象 sqlStr 要执行的sql语句 param执行SQL的语句参数化传递 输出参数: 执行结果对象 错误对象输出

func GpSqlSelect

func GpSqlSelect(dbs *sql.DB, model GpDBStruct, sqlStr string, param ...interface{}) (*sql.Rows, error)

查询方法 create by gloomy 2017-3-30 16:04:53 dbs数据库连接对象 model数据库对象 sqlStr 要执行的sql语句 param执行SQL的语句参数化传递 查询返回条数 错误对象输出

func HttpGetDownFile

func HttpGetDownFile(urlPathStr, saveFilePath string) error

get文件下载 create by gloomy 2017-08-28 15:33:17

func HttpSendFile

func HttpSendFile(sendHttpUrl, filePathStr, uploadFile string) error

* 文件发送处理方法 创建人:邵炜 创建时间:2016年11月29日15:37:06 输入参数:文件路径 输出参数:错误对象00001

func If

func If(condition bool, trueVal, falseVal interface{}) interface{}

* 构建三元运算 创建人:邵炜 创建时间:2017年2月8日18:51:36 输入参数:是否匹配 第一返回数 第二返回数

func LogInit

func LogInit(debug bool, logsDir string)

日志初始化 当程序停止前需将glog进行关闭 调用glog.Close方法 create by gloomy 2017-9-24 14:23:45

func MustCompileMatch

func MustCompileMatch(matchStr, str string) bool

匹配规则是否存在 create by gloomy 2017-09-07 21:13:30

func MySqlClose

func MySqlClose(dbs *sql.DB)

* 数据库关闭 创建人:邵炜 创建时间:2017年03月11日16:14:50 输入参数:数据库连接对象

func MySqlSQlConntion

func MySqlSQlConntion(model MySqlDBStruct) (*sql.DB, error)

* 数据库连接 创建人:邵炜 创建时间:2017年03月11日15:56:06 输入参数:数据库对象 输出对象:数据库连接对象

func MySqlSelect

func MySqlSelect(dbs *sql.DB, model MySqlDBStruct, sqlStr string, param ...interface{}) (*sql.Rows, error)

* 查询方法 创建人:邵炜 创建时间:2015年12月29日17:26:41 修正时间:2017年03月11日16:21:45 输入参数: dbs数据库连接对象 model数据库对象 sqlStr 要执行的sql语句 param执行SQL的语句参数化传递 输出参数: 查询返回条数 错误对象输出

func MySqlSqlExec

func MySqlSqlExec(dbs *sql.DB, model MySqlDBStruct, sqlStr string, param ...interface{}) (sql.Result, error)

* 数据库运行方法 创建人:邵炜 创建时间:2015年12月29日17:33:06 修正时间:2017年03月11日16:21:36 输入参数: dbs数据库连接对象 model数据库对象 sqlStr 要执行的sql语句 param执行SQL的语句参数化传递 输出参数: 执行结果对象 错误对象输出

func MysqlSelectMap

func MysqlSelectMap(dbs *sql.DB, model MySqlDBStruct, sqlStr string, param ...interface{}) (*[]map[string]string, error)

查询返回map create by gloomy 2018-01-16 17:52:15

func MysqlSelectUnknowColumn

func MysqlSelectUnknowColumn(dbs *sql.DB, model MySqlDBStruct, sqlStr string, param ...interface{}) (*[]string, *[][]string, error)

查询所有字段值 create by gloomy 2017-5-12 16:38:58

func OpenRedis

func OpenRedis(addr string, idx int) error

redis通道开启 create by gloomysw 2017-3-24 14:18:03 addr IP地址+端口 idx 仓库数

func PathExists

func PathExists(path string) (bool, error)

* 判断文件或文件夹是否存在 创建人:邵炜 创建时间:2016年12月21日17:07:42 输入参数:需要查询的文件或文件夹路径 输出参数:返回值true存在 否则不存在 错误对象

func PictureBase64ToFile

func PictureBase64ToFile(fileContentTem *string, filePath string) (string, error)

* base64图片转图片文件 创建人:邵炜 创建时间:2016年12月26日17:12:22 输入参数:图片base内容 图片文件存放路径(不包含图片名称) 输出参数:图片名称 错误对象

func RWFileByWhere

func RWFileByWhere(fileName string, fileWrite *os.File, where func(content string, fileWrite *os.File)) error

* 根据条件读文件 创建人:邵炜 创建时间:2017年3月22日11:03:31 输入参数:文件路径 文件写入对象 条件平判断方法 输出参数:错误对象

func ReadExcel

func ReadExcel(excelFilePath string) (*map[string][][]string, error)

excel数据获取 create by gloomy 2017-4-18 12:00:34 sheet名称 数据内容 错误对象

func ReadFileByLine

func ReadFileByLine(filePath string) (*[]string, error)

* 文件读取逐行进行读取 创建人:邵炜 创建时间:2016年9月20日10:23:41 输入参数: 文件路劲 输出参数: 字符串数组(数组每一项对应文件的每一行) 错误对象

func ReadFileLineNumber

func ReadFileLineNumber(filePathStr string) (int, error)

读取文件行数 create by gloomy 2017-6-2 14:00:32

func RmPidFile

func RmPidFile(pidFileStr string)

* 删除PID文件 创建人:邵炜 创建时间:2017年03月11日15:35:20 输入参数:pid文件路径

func Rounding

func Rounding(f float64, n int) float64

* 四舍五入取舍 create by gloomy 2017-03-29 22:11:18 需要取舍的浮点数 取舍几位

func RoundingByInt

func RoundingByInt(number, subNumber, n int) float64

* 四舍五入取舍 create by gloomy 2017-03-29 22:18:46 除数 被除数 取舍几位

func RoundingPercentageByInt

func RoundingPercentageByInt(number, subNumber, n int) float64

* 四舍五入取舍 百分比 create by gloomy 2017-03-29 22:18:46 除数 被除数 取舍几位

func SendEmail

func SendEmail(account, passWord, smtpUrl, smtpUrlPort, emailTitle string, emailContent *[]byte, toEmailUser []string, contentType string) error

发送邮件 create by gloomy 2017-04-12 11:18:23

func SetCPUUseNumber

func SetCPUUseNumber(number int)

* 设置CPU核心使用数 创建人:邵炜 创建时间:2021-03-18 11:13:25

func SetRedisCache

func SetRedisCache(key, value string, cacheBssSeconds int) error

设置redis缓存 create by gloomysw 2017-3-24 14:24:31 key 存储键名 value 存储值 cacheBssSeconds 存储时间(单位秒)

func SftpClose

func SftpClose(sftpClient *sftp.Client, sshClient *ssh.Client) error

sftp 关闭 create by gloomy 2017-05-10 12:06:05

func SftpReadDir

func SftpReadDir(sftpModel SftpConfigStruct, sftpClient *sftp.Client, sshClient *ssh.Client, pathStr string) (*[]os.FileInfo, error)

sftp读取文件夹内容 create by gloomy 2017-05-10 11:50:14

func UnGzip

func UnGzip(zipPathStr, filePathStr string) error

gz文件解压 create by gloomy 2017-09-04 20:27:24

func UnZip

func UnZip(zipPathStr, dirPathStr string) (string, error)

压缩文件解压 (方法暂时遗弃,解压会出现数据丢失) create by gloomy 2017-08-27 14:21:43

func UniqueSlice

func UniqueSlice(slice *[]string)

字符串数组去重 create by gloomy 2017-08-31 00:10:32

func WatchFile

func WatchFile(filePathStr, matchFileName string, deleteFileCallBack, modifyFileCallBack, renameFileCallBack, createFileCallBack func(string)) (*fsnotify.Watcher, error)

文件监控 create by gloomy 2017-5-3 11:42:09

func WatchFileAutoMated

func WatchFileAutoMated(filePath string, callBack func(string))

自动化创建任务 需要监控的文件,判断文件是否上传完毕 创建人:邵炜 创建时间:2016年9月5日14:58:13 输入参数: 文件路劲

func WritePid

func WritePid(pidFileStr string)

* 写PID文件 创建人:邵炜 创建时间:2017年03月11日15:47:11 输入参数:文件路径

func XmlContentReplace

func XmlContentReplace(value string) string

生成xml文件修正xml节点内容 create by gloomysw 2017-5-25 16:18:11

Types

type FileDataRecording

type FileDataRecording struct {
	sync.Mutex                         // 锁
	F                         *os.File // 文件对象
	FilePre                   string   // 文件开头字符串
	Fn                        string   // 文件路径
	Bytes                     int      // 文件大小
	Seq                       int      // 第几个
	FileProgram               string   // 文件存放路径
	MaxFileDataRecordingBytes int      // 文件大小
}

文件数据记录对象 create by gloomy 2017-04-06 10:15:00

func OpenLoadFile

func OpenLoadFile(fileProgram, filePre string, maxSize int) *FileDataRecording

打开文件数据记录 create by gloomy 2017-04-06 10:17:38 文件存放目录地址 文件开头字符串 文件大小 文件数据对象

func (*FileDataRecording) Close

func (f *FileDataRecording) Close()

文件关闭 create by gloomy 2017-04-06 10:22:14

func (*FileDataRecording) CreateNewFile

func (f *FileDataRecording) CreateNewFile() (err error)

创建新文件 create by gloomy 2017-04-06 10:33:11 错误对象

func (*FileDataRecording) Exit

func (f *FileDataRecording) Exit()

文件退出 create by gloomy 2017-04-06 10:27:58

func (*FileDataRecording) FileList

func (f *FileDataRecording) FileList() *[]string

获取所有完成的文件列表 create by gloomy 2017-04-06 13:46:51 文件列表

func (*FileDataRecording) RemoveOldFileList

func (f *FileDataRecording) RemoveOldFileList(days int)

删除过期文件 create by gloomy 2017-04-06 22:53:17 几天前

func (*FileDataRecording) Rotate

func (f *FileDataRecording) Rotate()

文件切换 create by gloomy 2017-04-06 10:30:05

func (*FileDataRecording) WriteData

func (f *FileDataRecording) WriteData(dataStr string) (err error)

写入数据 create by gloomy 2017-04-06 11:40:55 需要写入的数据 错误对象

type FtpHelpStruct

type FtpHelpStruct struct {
	IpAddr    string        // ip 地址
	Port      int           // 端口
	TimeOut   time.Duration // 超时时间
	UserName  string        // 用户名
	PassWord  string        // 密码
	FilePaths string        // 目标服务器路径
}

FTP帮助类实体 create by gloomy 2017-4-1 17:34:16

type GpDBStruct

type GpDBStruct struct {
	DbUser       string //数据库用户名
	DbHost       string //数据库地址
	DbPort       int    //数据库端口
	DbPass       string //数据库密码
	DbName       string //数据库库名
	MaxOpenConns int    // 用于设置最大打开的连接数,默认值为0表示不限制
	MaxIdleConns int    // 用于设置闲置的连接数
}

GP数据库连接对象 create by gloomy 2017-3-30 15:27:26

type LoadFile

type LoadFile map[string]string

StringMap is a map[string]string.

func (LoadFile) MarshalXML

func (s LoadFile) MarshalXML(e *xml.Encoder, start xml.StartElement) error

StringMap marshals into XML.

type MySqlDBStruct

type MySqlDBStruct struct {
	DbUser       string //数据库用户名
	DbHost       string //数据库地址
	DbPort       int    //数据库端口
	DbPass       string //数据库密码
	DbName       string //数据库库名
	MaxOpenConns int    // 用于设置最大打开的连接数,默认值为0表示不限制
	MaxIdleConns int    // 用于设置闲置的连接数
}

* 数据库连接对象 创建人:邵炜 创建时间:2017年03月11日16:01:20

type RequestData

type RequestData struct {
	ResultCode string //返回码
	Message    string //返回消息信息
}

接口返回对象 create by gloomy 2017-5-10 18:06:44

type SftpConfigStruct

type SftpConfigStruct struct {
	Account      string // 登录用户名
	Password     string // 登录密码
	Port         int    // 服务器端口
	ConntionSize int    // MaxPacket sets the maximum size of the payload
	Addr         string // 连接地址
}

sftp配置类 create by gloomy 2017-05-09 20:21:07

Directories

Path Synopsis
Package captcha implements generation and verification of image and audio CAPTCHAs.
Package captcha implements generation and verification of image and audio CAPTCHAs.
capexample
example of HTTP server that uses the captcha package.
example of HTTP server that uses the captcha package.
capgen
capgen is an utility to test captcha generation.
capgen is an utility to test captcha generation.
capgensounds
generate is a tool to generate sounds.go from WAVE files.
generate is a tool to generate sounds.go from WAVE files.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL