gops

package
v1.1.13 Latest Latest
Warning

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

Go to latest
Published: Mar 7, 2025 License: MulanPSL-2.0 Imports: 18 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BackgroundCronExecuteWithInterval added in v1.1.8

func BackgroundCronExecuteWithInterval(execution func(), duration time.Duration, done <-chan struct{})

BackgroundCronExecuteWithInterval 启动后台执行函数,每隔 duration 执行一次,并在后台独立运行,不阻塞主进程

func ExecCommand

func ExecCommand(command string, timeout ...int) (string, error)

ExecCommand 执行shell命令 command 为要执行的命令 timeout 为超时时间

func ForegroundCronExecuteWithInterval added in v1.1.8

func ForegroundCronExecuteWithInterval(execution func(), duration time.Duration)

ForegroundCronExecuteWithInterval 执行函数,并每隔 duration 执行一次,阻塞进程执行

func GetCurrentTime

func GetCurrentTime() string

GetCurrentTime 获取当前时间的标准格式字符串

func GetCurrentTimestamp

func GetCurrentTimestamp() int64

GetCurrentTimestamp 获取当前时间戳(秒级)

func GinErrorResponse added in v1.1.12

func GinErrorResponse(c *gin.Context, message string)

ErrorResponse 用于创建错误响应

func GinSuccessResponse added in v1.1.12

func GinSuccessResponse(c *gin.Context, data interface{})

SuccessResponse 用于创建成功响应

func GinValidateToken added in v1.1.12

func GinValidateToken(expectedToken string) gin.HandlerFunc

GinValidateToken 中间件:验证请求头token

func Md5File added in v1.1.8

func Md5File(filename string) (string, error)

Md5File 计算指定文件的MD5哈希值。

func Md5Str added in v1.1.8

func Md5Str(s string) (res string, err error)

Md5 计算指定字符串的MD5哈希值

func NewMail

func NewMail(config *NewMailConfig) *mailer

func PrintBlueMessage added in v1.1.3

func PrintBlueMessage(message string)

func PrintGreenMessage added in v1.1.3

func PrintGreenMessage(message string)

func PrintRedMessage added in v1.1.3

func PrintRedMessage(message string)

func PrintYellowMessage added in v1.1.3

func PrintYellowMessage(message string)

func RunPrompt

func RunPrompt[T any](label string, items []T) (string, error)

使用泛型定义RunPrompt

func SendQwMarkdownMessage added in v1.1.7

func SendQwMarkdownMessage(token string, markdownContent string) error

SendMarkdownMessage 发送企业微信 Markdown 消息

func SyncOne

func SyncOne()

Types

type CustomeResponse added in v1.1.11

type CustomeResponse struct {
	Code    int    `json:"code"`
	Msg     string `json:"msg"`
	Content any    `json:"content"`
}

func RequestGet added in v1.1.9

func RequestGet(options *RequestGetOptions) (res CustomeResponse, err error)

func RequestPost added in v1.1.9

func RequestPost(options *RequestPostOptions) (res CustomeResponse, err error)

RequestPost 函数用于发送POST请求

type NewMailConfig added in v1.1.6

type NewMailConfig struct {
	Host     string `json:"host"`
	User     string `json:"user"`
	Password string `json:"password"`
	Port     int    `json:"port"`
	SmtpSSL  bool   `json:"smtp_ssl"`
}

type RequestGetOptions

type RequestGetOptions struct {
	URL     string            `json:"url"`
	Params  map[string]string `json:"params"`
	Headers map[string]string `json:"headers"`
}

type RequestPostOptions

type RequestPostOptions struct {
	URL     string            `json:"url"`
	Data    map[string]any    `json:"data"`
	Headers map[string]string `json:"headers"`
}

RequestPostOptions 结构体用于封装POST请求的选项

Jump to

Keyboard shortcuts

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