package
0.0.0-20250120021636-22a6110bc63b
Repository: https://github.com/wengoldx/xcore.git
Documentation: pkg.go.dev

# Functions

Allow cross domain access for localhost, the port number must config in /conf/app.conf file like : --- ; Server port of HTTP httpport=3200.
Add a single monitor task to list.
Return birthday as time from given ID Card string.
Return gender from given ID Card string, true is male, false is female.
Condition return the trueData when pass the condition, or return falseData `USAGE` : // use as follow to return diffrent type value, but the input // true and false params MUST BE no-nil datas.
Contain check the given string list if contains item.
Contain check the given int list if contains item.
Contain check the given int64 list if contains item.
ContainInt64s check the given int64 items if contains in totals.
ContainInts check the given int items if contains in totals.
Contains check the given strings items if contains in totals.
CopyFile Copy source file to traget file.
CopyFileTo copy source file to given dir.
DayDiff return diff days, hours, minutes, seconds.
DaysUnix return the unix time at 0:00:00, by offset days.
DayUnix return the given day unix time at 0:00:00.
DeleteFile delete file.
DeletePath delete files and directory.
Distinct remove duplicate string from given array.
Distinct remove duplicate int64 from given array.
Distinct remove duplicate int from given array.
DurDays return readable time during start to end like 2d 6h 25m 48s, you can set the format string, but it must contain 4 %0xd to parse numbers.
DurHours return readable time during start to end like 06:25:48, you can see the format string, but it must contain 3 %0xd to parse numbers.
DurNowNs return formated second string from given start in unix nanoseconds.
EncodeUrl encode url params.
EnsurePath check the given file path, or create new one if unexist.
ExistInt64s check the given int64 items if any exist in totals.
ExistInts check the given int items if any exist in totals.
ExistStrings check the given string items if any exist in totals.
FileMD5 encode file content to md5 string.
FixPath fix path, example: --- /aaa/aa\\bb\\cc/d///// -> /aaa/aa/bb/cc/d E:/aaa/aa\\bb\\cc/d////e/ -> E:/aaa/aa/bb/cc/d/e "" -> .
FormatDay format day string from given unix seconds as '2006-01-02', or custom format like '2006/01/02', '2006.01.02' and so on.
FormatDur format the time before or after now by add given duration, it may format as TimeLayout when input layout not set, and the formated time contain location timezoom.
FormatNow format now to given time layout, it may format as TimeLayout when input param not set, and the formated time contain location timezoom.
FormatTime format unix time to TimeLayout or MSLayout layout.
FormatToday format now to today string as '2006-01-02', or custom format set by layout like '2006/01/02', '2006.01.02' and so on.
FormatUnix format unix time to given time layout with location timezoom.
Deprecated: use utils.NewQTask instead it.
Deprecated: use utils.NewQueue instead it.
Deprecated: use utils.NewQTask instead it.
GetIP get just ip not port from controller.Ctx.Request.RemoteAddr of beego.
GetLocalIPs get all the loacl IP of current deploy machine.
GetSortKey get first letter of Chinese Pinyin.
Return task if exist, or nil when unexist.
No description provided by the author
Check the variable params, return the first value if exist any, or return default string, int, int64.
HourDiff return diff hours, minutes, seconds.
HttpClientGet handle http get by http.Client, you can set request headers or ignore TLS verfiy of https url by setRequstFunc middle-ware function as : --- resp, err := comm.HttpClientGet(tagurl, func(req *http.Request) (bool, error) { req.Header.Set("Content-Type", "application/json;charset=UTF-8") req.SetBasicAuth("username", "password") // set auther header return true, nil // true is ignore TLS verify of https url }, "same-params");.
HttpClientGetStruct handle http get method and unmarshal data to struct object.
HttpClientPost handle https post by http.Client, you can set request headers or ignore TLS verfiy of https url by setRequstFunc middle-ware function as : --- resp, err := comm.HttpClientPost(tagurl, func(req *http.Request) (bool, error) { req.Header.Set("Content-Type", "application/json;charset=UTF-8") req.SetBasicAuth("username", "password") // set auther header return true, nil // true is ignore TLS verify of https url }, "post-data").
HttpClientPostStruct handle http post method and unmarshal data to struct object.
HttpGet handle http get method.
HttpGetString call HttpGet and trim " char both begin and end.
HttpGetStruct handle http get method and unmarshal data to struct object.
HttpPost handle http post method, you can set content type as comm.ContentTypeJson or comm.ContentTypeForm, or other you need set.
HttpPostString call HttpPost and trim " char both begin and end.
HttpPostStruct handle http post method and unmarshal data to struct object.
Start and excute http server base on beego, by default, it just support restful interface not socket.io connection, but you can set allowCredentials as true to on socket.io conect function.
HumanReadable format the size number of len.
Indicate given object if the target type.
IsDir check whether dir path point to a directory.
IsDir2 check whether file point to a directory.
IsExistFile check whether the file exists.
IsFile check whether file path point to a file.
IsFile2 check whether file point to a file.
IsSameDay equal given days string based on TimeLayout, the src and des time string must format by time.Format() or offseted timezoom.
IsSameTime equal given time string based on TimeLayout, the src and des time string must format by time.Format() or offseted timezoom.
IsToday check the given day string if today, the des time string must format by time.Format() or offseted timezoom.
IsTodayUnix check the given time string if today, the des time unix seconds from time.Now() or contian timezoom.
Verify ID Card internal, just simple validate card number only.
Verify Nation abbreviation if validate on 3 chars.
JoinFloats join float64 numbers as string '0.1,2,3.45' with ',' default separator, or custom separator '-' like '0.1-2-3.45'.
JoinInt64s join int64 numbers as string '1,2,3' with ',' default separator, or custom separator '-' like '1-2-3'.
JoinInts join int numbers as string '1,2,3' with ',' default separator, or custom separator '-' like '1-2-3'.
JoinLines combine strings into multiple lines.
MakeDirs create new directory, by default perm is 0777.
MonthsUnix return unix time at 0:00:00, by offset months.
MonthUnix return next month day (same as current day of month) unix time at 0:00:00.
Create a new task monitor instance.
Create a new queue instance.
Create a sets instance.
NewSmsSender create a sms sender for given cloud service.
Create a new stack instance.
Create a new time wheel.
NextHalfYear return next half a year unix time start from current, or from the given unix seconds and nano seconds.
NextMonth return next month unix time start from current, or from the given unix seconds and nano seconds.
NextQuarter return next quarter unix time start from current, or from the given unix seconds and nano seconds.
NextTime return next unix time start from current, or from the given unix seconds and nano seconds.
NextUnix return next 0:00:00 unix time at day after given duration.
NextUnix2 return next 0:00:00 unix time at day after given years, months and days.
NextWeek return next week unix time start from current, or from the given unix seconds and nano seconds.
NextYear return next year unix time start from current, or from the given unix seconds and nano seconds.
OpenFileTrunc create new file for trunc content, by default perm is 0666.
OpenFileWrite create new file for write content, by default perm is 0666.
ParseTime parse time with zoom, the src time string maybe formated from time.Format() return value.
QuartersUnix return unix time at 0:00:00, by offset quarters.
QuarterUnix return next quarter unix time at 0:00:00.
ReadPropFile read properties file on filesystem.
Reversal int64s string to int64 array with default separator , char or custom separator.
Reversal ints string to int array with default separator , char or custom separator.
SaveB64File save base64 encoded buffer to target file.
SaveFile save file buffer to target file.
No description provided by the author
SilentClientGet call httpUtils.ClientGet() on silent state.
SilentClientGetStruct call httpUtils.ClientGetStruct() on silent state.
SilentClientPost call httpUtils.ClientPost() on silent state.
SilentClientPostStruct call httpUtils.ClientPostStruct() on silent state.
SilentGet call httpUtils.Get() on silent state.
SilentGetString call httpUtils.GetString() on silent state.
SilentGetStruct call httpUtils.GetStruct() on silent state.
SilentPost call httpUtils.Post() on silent state.
SilentPostString call httpUtils.PostString() on silent state.
SilentPostStruct call httpUtils.PostStruct() on silent state.
Start and excute both restful and socket.io server.
SplitAfterTrim extend strings.SplitAfter to trim all space chars and sub strings.
SplitTrim extend strings.Split to trim space and sub strings before split.
Create tasks and start them as monitors.
To2Digits fill zero if input digit not enough 2.
To2Digits fill zero if input digit not enough 3.
Today return today unix time with offseted location timezoom.
TodayUnix return today unix time at 0:00:00.
ToMap transform given struct data to map data, the transform struct feilds must using json tag to mark the map key.
Tommorrow return tommorrow unix time srart from current location time.
TommorrowUnix return tommorrow unix time at 0:00:00.
ToNDigits fill zero if input digit not enough N.
ToXMLReplace transform given struct data to xml string, ant then replace indicated fileds or values, to form param must not empty, but the to param allow set empty when use to remove all form keyworlds.
ToXMLString transform given struct data to xml string.
TrimEmpty remove empty string, it maybe return empty result array.
Try try-catch-finaly method.
Parse total routers and update description on chinese for local server routers, then marshal to string for next to push to nacos config server.
Parse total routers and update description on chinese for local server routers, then marshal to string for next to push to nacos config server.
Return the first element int (> 0), or default if empty.
Return the first element int64 (> 0), or default if empty.
Return the first element string, or default if empty.
VerifyFile verify upload file and size, it support jpg/jpeg/JPG/JPEG/png/PNG/mp3/mp4 suffix.
VerifyFileFormat verify upload file and size in MB.
WeekUnix return unix time at 0:00:00, by offset weeks.
WeekUnix return next week day (same as current weekday) unix time at 0:00:00.
YearsUnix return unix time at 0:00:00, by offset years.
YearUnix return next year unix time at 0:00:00.
Yesterday return yesterday unix time base on current location time.
YesterdayUnix return yesterday unix time at 0:00:00.

# Constants

ContentTypeForm form content type.
ContentTypeJson json content type.
DateLayout standery date layout format at day minimum.
DateNoneHyphen standery time layout format at second minimum without hyphen char.
Day, week, duration on nanosecond.
Day, week, duration on millisecond.
Day, week duration on second.
feed card message content type.
action card message content type.
link message content type.
markdown message content type.
text message content type.
HourLayout standery time layout format as hour.
HourNoneHyphen standery time layout format as hour without hyphen char.
MSLayout standery time layout format at million second minimum.
MSNoneHyphen standery time layout format at million second minimum without hyphen char.
TimeLayout standery time layout format at second minimum.
TimeNoneHyphen standery time layout format at second minimum without hyphen char.
Day, week, duration on nanosecond.
Day, week, duration on millisecond.
Day, week duration on second.

# Variables

Empty map value for simulate Set type.
No description provided by the author

# Structs

No description provided by the author
DTalkSender message sender for DingTalk custom robot, it just support inited with keywords, secure token functions, but not ips range sets.
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
DTMsgActionCard Action card type message with one click action.
DTMsgFeedCard Feed card type message.
DTMsgLink Link type message.
DTMsgMarkdown Markdown type message.
DTMsgSplitAction Action card type message with split button actions.
DTMsgText Text type message.
No description provided by the author
No description provided by the author
EmailContent email template.
Empty struct regard as map value occupy 0 memery size to simulate sets type.
A group informations.
MailAgent mail agent informations `Useage` --- mailTempleteSubject = "You hava a mail!" mailTemplateFormat = ` <p> <span font-weight:bold; style="font-size:16px; color:#363636">Dear</span><br><br> <span style="font-size:14px; color:#484848">Your account %s have not activate, please click the follow link to activate it.</span><br> <span style="font-size:14px; color:#484848">%s</span><br> </p> <p align="right"> <span style="font-size:12px; color:#484848">From %s</span><br> <span style="font-size:10px; color:#636363">%s</span> </p> ` mailagent = &comm.MailAgent{ Acc: account, Pwd: password, Host: smtphost, Port: smtpport, } subject := mailTempleteSubject message := fmt.Sprintf(mailTemplateFormat, account, link, who, time.Now().Format(templateTimeFormat)) // send mail with attachment // return ma.SendMail(to, subject, message, fileName) return ma.SendMail(to, subject, message).
Task monitor to execute queue tasks in sequence.
Queue the type of queue with sync lock --------- <- Head Quere Top : | 1 | -> Pop +-------+ | 2 | +-------+ | ..
A router informations.
All routers of one server.
Sets type for cache different types and unique value datas.
SmsContent sms template.
SmsSender sender, including smtp authtication and user info.
Stack the type of stack with sync lock Push -> + + -> Pop \ / +-------+ Stack Top : | n | +-------+ | ..
No description provided by the author
TimeWheel delay task sets.
No description provided by the author
Task datas for multipe generate.

# Type aliases

No description provided by the author
SetRequest use for set http request before execute http.Client.Do, you can use this middle-ware to set auth as username and passord, and so on.
TaskCallback task callback function.