cob

package module
v1.0.7 Latest Latest
Warning

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

Go to latest
Published: May 15, 2023 License: Apache-2.0 Imports: 33 Imported by: 0

README

cob

Documentation

Index

Constants

This section is empty.

Variables

View Source
var DAudio = &Audio{}
View Source
var DExcel = &Excel{}
View Source
var DHttp = &Http{}
View Source
var DNepal = &Nepal{}
View Source
var DQiniu = &Qiniu{
	AccessKey: "xxx",
	SecretKey: "xxx",
	Bucket:    "images-mkd",
	Zone:      &storage.ZoneHuanan,
	Domain:    "http://image.youthsweet.com",
}

Functions

This section is empty.

Types

type Audio added in v1.0.7

type Audio struct{}

func (*Audio) ConvertMggToMp3 added in v1.0.7

func (obj *Audio) ConvertMggToMp3(umPath string, ffmpegPath string, mggPath string, oggPath string, mp3Path string, maxG int)

ConvertMggToMp3 格式化文件名、解密、转换一步到位

func (*Audio) ConvertMggToOgg added in v1.0.7

func (obj *Audio) ConvertMggToOgg(umPath string, mggPath string, oggPath string)

ConvertMggToOgg 通过um将mgg格式解密为ogg格式

func (*Audio) ConvertOggToMp3 added in v1.0.7

func (obj *Audio) ConvertOggToMp3(ffmpegPath string, oggPath string, mp3Path string)

ConvertOggToMp3 通过ffmpeg将ogg转换为mp3格式

func (*Audio) ConvertOggToMp3Async added in v1.0.7

func (obj *Audio) ConvertOggToMp3Async(ffmpegPath string, oggPath string, mp3Path string, maxG int)

ConvertOggToMp3Async 通过ffmpeg将ogg转换为mp3格式,并发模式

func (*Audio) DeleteFilenameBlank added in v1.0.7

func (obj *Audio) DeleteFilenameBlank(root string)

DeleteFilenameBlank 遍历目录,删除文件名中的空格并重命名

type DingTalk added in v1.0.7

type DingTalk struct {
	Token  string // webhook中的token
	Secret string // 加签
}

DingTalk https://open.dingtalk.com/document/robots/customize-robot-security-settings

func NewDingTalk added in v1.0.7

func NewDingTalk(token string, secret string) *DingTalk

func (*DingTalk) SendMsgToDingDing added in v1.0.7

func (obj *DingTalk) SendMsgToDingDing(msg string) error

SendMsgToDingDing 钉钉机器人发送消息

type Excel added in v1.0.7

type Excel struct{}

func (*Excel) ExcelToSQL added in v1.0.7

func (obj *Excel) ExcelToSQL(filename string, sheetname string, tablename string, fields []string, is_column_mode bool) ([]string, error)

ExcelToSQL Excel转成SQL语句

func (*Excel) SliceToExcelBuff added in v1.0.7

func (obj *Excel) SliceToExcelBuff(s [][]interface{}) (buf *bytes.Buffer)

SliceToExcelBuff 将切片转换为Excel格式,并返回bytes.Buffer,可以保存为文件或写入http响应体

func (*Excel) SliceToExcelFile added in v1.0.7

func (obj *Excel) SliceToExcelFile(s [][]interface{}, path string, filename string) (err error)

SliceToExcelFile 将切片写入Excel文件

func (*Excel) SliceToGinResp added in v1.0.7

func (obj *Excel) SliceToGinResp(s [][]interface{}, filename string, context *gin.Context)

SliceToGinResp 将切片写入Excel文件,写入http响应体,实现Excel文件下载

func (*Excel) StructSliceToGinResp added in v1.0.7

func (obj *Excel) StructSliceToGinResp(slice interface{}, filename string, context *gin.Context)

StructSliceToGinResp 将结构体切片写入Excel文件,写入http响应体,实现Excel文件下载

func (*Excel) StructToSlice added in v1.0.7

func (obj *Excel) StructToSlice(slice interface{}, addFieldName bool) [][]interface{}

StructToSlice 将任意结构体切片转换为二维切片[][]interface{},addFieldName是否添加字段名

type Http added in v1.0.7

type Http struct{}

func (*Http) CreateFileServer added in v1.0.7

func (obj *Http) CreateFileServer(localPath string, relativePath string, port string, OnlyListenLocalAddr bool)

CreateFileServer 创建一个HTTP文件服务器,注意relativePath路径后要加斜杠 example:DNepal.CreateFileServer("C:\\lee\\project\\go\\auto", "/static/", "8888", true)

func (*Http) CreateFileServerByGin added in v1.0.7

func (obj *Http) CreateFileServerByGin(localPath string, relativePath string, port string, OnlyListenLocalAddr bool)

CreateFileServerByGin 创建一个HTTP文件服务器,通过gin框架

func (*Http) CreateHttpProxyClient added in v1.0.7

func (obj *Http) CreateHttpProxyClient(proxy string, timeout int) *http.Client

CreateHttpProxyClient 创建一个http代理客户端,代理类型由uri确定,支持http/https/socks5,默认为http http://fans007:fans888@45.76.169.156:39000

func (*Http) TestMulHttpProxy added in v1.0.7

func (obj *Http) TestMulHttpProxy(proxys []string, timeout int, maxG int, printLog bool) (success []string, fail []string)

TestMulHttpProxy 批量测试多个HTTP代理

func (*Http) TestOneHttpProxy added in v1.0.7

func (obj *Http) TestOneHttpProxy(proxy string, timeout int) (string, error)

TestOneHttpProxy 测试单个http代理是否可用

type Mail

type Mail struct {
	Username string // 邮箱地址
	Password string // 邮箱授权码,非密码
}

Mail Gmail https://www.codenong.com/cs105864356/ 1.开启两步验证 2.创建专用密码 3.选择customer类型 Gmail 国内网络可能会超时

func NewMail added in v1.0.7

func NewMail(username, password string) *Mail

func (*Mail) SendEmail

func (obj *Mail) SendEmail(to string, subject string, body string) error

type Nepal added in v1.0.7

type Nepal struct{}

func (*Nepal) GetRandomNum added in v1.0.7

func (obj *Nepal) GetRandomNum(N, M int) (result int)

GetRandomNum 获取N~M之间的随机整数,N<=M

func (*Nepal) GetRandomString added in v1.0.7

func (obj *Nepal) GetRandomString(n int) (result string)

GetRandomString 获取偶数位随机字符串

func (*Nepal) GetRootPath added in v1.0.7

func (obj *Nepal) GetRootPath() (root string)

GetRootPath 获取项目根路径,请将函数复制到自己的项目中使用,不能直接调用!

func (*Nepal) ReadFileToSlice added in v1.0.7

func (obj *Nepal) ReadFileToSlice(filepath string) (lines []string)

ReadFileToSlice 将文件中的所有非空行读入切片

func (*Nepal) StructToSlice added in v1.0.7

func (obj *Nepal) StructToSlice(slice interface{}, addFieldName bool) [][]interface{}

StructToSlice 将任意结构体切片转换为二维切片[][]interface{}

type Qiniu added in v1.0.7

type Qiniu struct {
	AccessKey string // 秘钥对
	SecretKey string
	Bucket    string        // 空间(桶)
	Zone      *storage.Zone // 地域:
	Domain    string
}

func (*Qiniu) DeleteFile added in v1.0.7

func (obj *Qiniu) DeleteFile(filename string) error

DeleteFile 删除bucket中的文件

func (*Qiniu) GetOutsideChain added in v1.0.7

func (obj *Qiniu) GetOutsideChain(prefix string) (urls []string)

GetOutsideChain 根据前缀匹配获取外链

func (*Qiniu) PutFile added in v1.0.7

func (obj *Qiniu) PutFile(filepath string, filename string)

PutFile 上传文件

func (*Qiniu) SyncLocalToQiniu added in v1.0.7

func (obj *Qiniu) SyncLocalToQiniu(localDir string, qiniuDir string, minute int)

SyncLocalToQiniu 同步本地目录到七牛,若minute=30,即只同步最近半小时的新文件

type SSHClient added in v1.0.7

type SSHClient struct {
	User    string
	Pass    string
	Key     string // 私钥文件路径,公钥需写入服务器的authorized_keys
	Host    string
	Port    int
	Timeout int
	Session *ssh.Session
	Client  *ssh.Client
}

func (*SSHClient) CreateSession added in v1.0.7

func (obj *SSHClient) CreateSession() (*ssh.Session, error)

CreateSession 创建ssh会话

func (*SSHClient) RunOneCmd added in v1.0.7

func (obj *SSHClient) RunOneCmd(cmd string) (string, error)

RunOneCmd 执行单个命令,返回结果

func (*SSHClient) RunScriptFile added in v1.0.7

func (obj *SSHClient) RunScriptFile(file string) (string, error)

RunScriptFile 执行脚本文件

func (*SSHClient) UploadFile added in v1.0.7

func (obj *SSHClient) UploadFile(localFile string, remoteFile string) error

UploadFile 上传文件

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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