utils

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Nov 5, 2023 License: Apache-2.0 Imports: 22 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ErrCode    = 1
	ModuleCode = 100 * ErrCode
	ServerCode = ModuleCode * 100
)

错误代码100101,其中 10 代表发布平台服务;中间的 01 代表发布平台服务下的文章模块;最后的 01 代表模块下的错误码序号,每个模块可以注册 100 个错误 0代表成功

View Source
const (
	ServerPublishCode   = 25 * ServerCode //发布平台
	ServerStatisticCode = 26 * ServerCode //统计服务
)

服务代码

View Source
const (
	PublishArticleCode      = 1 * ModuleCode //文章模块
	PublishFileCode         = 2 * ModuleCode //文件模块
	PublishNotificationCode = 3 * ModuleCode //通知模块
)

发布平台相关模块

View Source
const (
	PublishArticlePublishFailed          = 1 * ErrCode //发布失败
	PublishArticleSaveFailed             = 2 * ErrCode //保存失败
	PublishArticleUploadFailed           = 3 * ErrCode //上传文件失败
	PublishArticleDeleteFailed           = iota + 1    //文章删除失败			4
	PublishArticleQueryFailed                          //查询失败			5
	PublishArticlePushNoticeCreateFailed               //推送通知创建失败		6
	PublishArticleListStandard                         //查询行业规范列表失败	7
	PublishArticleDeleteArticleBatch                   //批量删除文章失败		8
	PublishArticleDeleteArticle                        //删除文章失败			9
	PublishArticleEditArticle                          //编辑文章失败			10
)

发布平台文章模块错误码

Variables

This section is empty.

Functions

func DiffNatureDays

func DiffNatureDays(t1, t2 int64) int

DiffNatureDays

@description:	两个日期的相差的自然天数
@param:
@author:	GJing
@email:		gjing1st@gmail.com
@date:		2022/11/16 11:22
@success:

func Div

func Div(Num int) string

Div 数字转字母

func Float64

func Float64(any interface{}) float64

Float64

@description:	接口类型转float64
@param:			any 接口类型
@author:		GJing
@email:			guojing@tna.cn
@date:			2022/4/22 10:44
@success:		float64

func InArray

func InArray(value string, arr []string) bool

InArray

@description:	判断一个字符串是否在数组中
@param:
@author:	GJing
@email:		gjing1st@gmail.com
@date:		2020/11/13 14:42
@success:

func Int

func Int(any interface{}) int

Int

@description:	转int
@param:
@author:	GJing
@email:		guojing@tna.cn
@date:		2022/4/22 11:13
@success:

func Int64

func Int64(any interface{}) int64

Int64

@description:	接口类型转int64
@param:			any 接口类型
@author:		GJing
@email:			guojing@tna.cn
@date:			2022/4/22 10:56
@success:		int64

func LeDecodeToFloat64

func LeDecodeToFloat64(b []byte) float64

func LeFillUpSize

func LeFillUpSize(b []byte, l int) []byte

func LogField

func LogField(err error, msg string) log.Fields

LogField

@description:	日志字段
@param:
@author:	GJing
@email:		gjing1st@gmail.com
@date:		2022/11/1 15:35
@success:

func Md5

func Md5(str string) string

Md5 Author: GJing Email: gjing1st@gmail.com Date: 2020/10/23 13:57 Description: md5加密

func PathExists

func PathExists(path string) (bool, error)

PathExists

@description:	判断文件是否存在
@param:
@author:	Zq
@email:		zhengqiang@tna.cn
@date:		2022/10/19 17:52
@success:

func ReserveNumber

func ReserveNumber(f float64, m int) string

ReserveNumber

@description:	截取保留小数点后m位,舍去后面位数
@param:			f float64
@param:			m 保留的位数
@author:		GJing
@email:			gjing1st@gmail.com
@date:			2020/11/25 上午 10:31
@success:		返回截取后的字符串

func Round

func Round(f float64, n int) float64

Round

@description:	四舍五入保留n位小数
@param:f		需要处理的float数
@param:n		需要保留的小数位数
@author:		GJing
@email:			gjing1st@gmail.com
@date:			2021/1/23 10:36
@success:

func RunCommand

func RunCommand(name string, arg ...string) (err error)

RunCommand

@description:	运行系统命令
@param:			cmdStr 要运行的命令
@author:		GJing
@email:			guojing@tna.cn
@date:			2022/9/2 17:46
@success:

func String

func String(any interface{}) string

String

@description:	转string类型
@param:			any 接口类型
@author:		GJing
@email:			guojing@tna.cn
@date:			2022/4/22 11:11
@success:		字符串

func UnExt

func UnExt(fileName string) string

UnExt

@description:	返回文件名称去掉后缀和最后一个`.`
@param:			fileName 文件名称
@author:		GJing
@email:			guojing@tna.cn
@date:			2022/7/28 15:39
@success:

func UnzipDir

func UnzipDir(zipFile, dir string)

UnzipDir

@description:	解压缩
@param:zipFile	压缩文件路径 ./test.zip
@param:dir		需要解压到的指定文件夹目录 ex :F:\dumps_copy
@author:		GJing
@email:			gjing1st@gmail.com
@date:			2021/1/13 15:19
@success:

func WriteFile

func WriteFile(fileName, s string) (err error)

WriteFile

@description:
@param:
@author:	GJing
@email:		guojing@tna.cn
@date:		2022/9/2 17:52
@success:

Types

type Host

type Host struct {
	IP       string
	Password string
	User     string
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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