utility

package
v0.2.1 Latest Latest
Warning

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

Go to latest
Published: May 31, 2023 License: GPL-3.0 Imports: 23 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AcceptJSONResponse

func AcceptJSONResponse(ctx *gin.Context) bool

func CaptureException

func CaptureException(err error)

CaptureException 捕获异常并发送到sentry

func CaptureRequest

func CaptureRequest(r *http.Request)

CaptureRequest 捕获请求并发送到sentry

func CloseSentry

func CloseSentry()

RecoverPanic 恢复panic并发送到sentry

func EchoInfo

func EchoInfo(msg string)

func FetchURL

func FetchURL(verb string, url string, payload string, headers map[string]string) (int, string, error)

func FetchURLWithRetry

func FetchURLWithRetry(verb string, url string, payload string, headers map[string]string, retries int, retryInterval time.Duration) (int, string, error)

func GetBaseURL

func GetBaseURL(endpoint_url string) string

func GetCurrPath

func GetCurrPath() string

func GetYYYYMM

func GetYYYYMM() string

func GetYYYYMMDD

func GetYYYYMMDD() string

func InitSentry

func InitSentry(dsn string, is_client bool) error

InitSentry 初始化sentry

func IsValidEmail

func IsValidEmail(email string) bool

func IsValidURL

func IsValidURL(url_str string) bool

func Lookup

func Lookup(text string, lang string) (string, error)

查询字典函数,接受要查询的单词和目标语言代码,返回查询结果和错误信息

func ReportEvent

func ReportEvent(event_id UserDefinedEvent, eventMessage string, payLoad map[string]interface{})

ReportCustomEvent 上报定制事件

func SendEmail

func SendEmail(to, subject, body string) error

func SetExtra

func SetExtra(key string, value interface{})

func SetTag

func SetTag(key, value string)

func SetUser

func SetUser(id string)

func Translate

func Translate(text string, lang string) (string, error)

翻译函数,接受要翻译的文本和目标语言代码,返回翻译结果和错误信息

Types

type LogFile

type LogFile struct {
	FileHandle *os.File
	LogPath    string
	LogLevel   string
}

func NewLog

func NewLog(log_path string, name string, level string) *LogFile

func (*LogFile) Close

func (lf *LogFile) Close()

type UserDefinedEvent

type UserDefinedEvent int
const (
	// execute host command on local machine
	EVT_CLIENT_INIT UserDefinedEvent = iota
	EVT_CLIENT_CLOSE
	EVT_CLIENT_ASK_CHATGPT
	EVT_CLIENT_ANSWER_CHATGPT

	EVT_SERVER_INIT
	EVT_SERVER_CLOSE
	EVT_SERVER_PROXY_SUCCESS
	EVT_SERVER_PROXY_FAILED
)

type UserDefinedEventMeta

type UserDefinedEventMeta struct {
	Name  string
	Level sentry.Level
	Group string
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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