invar

package
v0.0.0-...-21fbc7d Latest Latest
Warning

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

Go to latest
Published: Dec 24, 2024 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Overview

Copyright (c) 2018-Now Dunyu All Rights Reserved.

Author : https://www.wengold.net Email : support@wengold.net

Prismy.No | Date | Modified by. | Description ------------------------------------------------------------------- 00001 2019/05/22 yangping New version -------------------------------------------------------------------

Copyright (c) 2018-Now Dunyu All Rights Reserved.

Author : https://www.wengold.net Email : support@wengold.net

Prismy.No | Date | Modified by. | Description ------------------------------------------------------------------- 00001 2019/05/22 yangping New version -------------------------------------------------------------------

Copyright (c) 2018-Now Dunyu All Rights Reserved.

Author : https://www.wengold.net Email : support@wengold.net

Prismy.No | Date | Modified by. | Description ------------------------------------------------------------------- 00001 2019/05/22 yangping New version -------------------------------------------------------------------

Index

Constants

View Source
const (
	Lang_arIL int // Arabic (Israel)
	Lang_arEG     // Arabic (Egypt)
	Lang_zhCN     // Chinese Simplified
	Lang_zhTW     // Chinese Tradition
	Lang_zhHK     // Chinese Hongkong
	Lang_nlNL     // Dutch(Netherlands)
	Lang_nlBE     // Dutch(Netherlands)
	Lang_enUS     // English(United States)
	Lang_enAU     // English(Australia)
	Lang_enCA     // English(Canada)
	Lang_enIN     // English(India)
	Lang_enIE     // English(Ireland)
	Lang_enNZ     // English(New Zealand)
	Lang_enSG     // English(Singapore)
	Lang_enZA     // English(South Africa)
	Lang_enGB     // English(United Kingdom)
	Lang_frFR     // French
	Lang_frBE     // French
	Lang_frCA     // French
	Lang_frCH     // French
	Lang_deDE     // German
	Lang_deLI     // German
	Lang_deAT     // German
	Lang_deCH     // German
	Lang_itIT     // Italian
	Lang_itCH     // Italian
	Lang_ptBR     // Portuguese
	Lang_ptPT     // Portuguese
	Lang_esES     // Spanish
	Lang_esUS     // Spanish
	Lang_bnBD     // Bengali
	Lang_bnIN     // Bengali
	Lang_hrHR     // Croatian
	Lang_csCZ     // Czech
	Lang_daDK     // Danish
	Lang_elGR     // Greek
	Lang_heIL     // Hebrew
	Lang_iwIL     // Hebrew
	Lang_hiIN     // Hindi
	Lang_huHU     // Hungarian
	Lang_inID     // Indonesian
	Lang_jaJP     // Japanese
	Lang_koKR     // Korean
	Lang_msMY     // Malay
	Lang_faIR     // Perisan
	Lang_plPL     // Polish
	Lang_roRO     // Romanian
	Lang_ruRU     // Russian
	Lang_srRS     // Serbian
	Lang_svSE     // Swedish
	Lang_thTH     // Thai
	Lang_trTR     // Turkey
	Lang_urPK     // Urdu
	Lang_viVN     // Vietnamese
	Lang_caES     // Catalan
	Lang_lvLV     // Latviesu
	Lang_ltLT     // Lithuanian
	Lang_nbNO     // Norwegian
	Lang_skSK     // slovencina
	Lang_slSI     // Slovenian
	Lang_bgBG     // bulgarian
	Lang_ukUA     // Ukrainian
	Lang_tlPH     // Filipino
	Lang_fiFI     // Finnish
	Lang_afZA     // Afrikaans
	Lang_rmCH     // Romansh
	Lang_myZG     // Burmese
	Lang_myMM     // Burmese
	Lang_kmKH     // Khmer
	Lang_amET     // Amharic
	Lang_beBY     // Belarusian
	Lang_etEE     // Estonian
	Lang_swTZ     // Swahili
	Lang_zuZA     // Zulu
	Lang_azAZ     // Azerbaijani
	Lang_hyAM     // Armenian
	Lang_kaGE     // Georgian
	Lang_loLA     // Laotian
	Lang_mnMN     // Mongolian
	Lang_neNP     // Nepali
	Lang_kkKZ     // Kazakh
	Lang_siLK     // Sinhala

)
View Source
const (
	// InvalidLangCode invalid language code
	InvalidLangCode int = -1

	// LangsSeparator multi-langguages separator
	LangsSeparator = ","
)
View Source
const (
	Angola              = "Angola"
	Afghanistan         = "Afghanistan"
	Albania             = "Albania"
	Algeria             = "Algeria"
	Andorra             = "Andorra"
	Anguilla            = "Anguilla"
	AntiguaBarbuda      = "Antigua and Barbuda"
	Argentina           = "Argentina"
	Armenia             = "Armenia"
	Ascension           = "Ascension"
	Australia           = "Australia"
	Austria             = "Austria"
	Azerbaijan          = "Azerbaijan"
	Bahamas             = "Bahamas"
	Bahrain             = "Bahrain"
	Bangladesh          = "Bangladesh"
	Barbados            = "Barbados"
	Belarus             = "Belarus"
	Belgium             = "Belgium"
	Belize              = "Belize"
	Benin               = "Benin"
	BermudaIs           = "Bermuda Is."
	Bolivia             = "Bolivia "
	Botswana            = "Botswana"
	Brazil              = "Brazil"
	Brunei              = "Brunei"
	Bulgaria            = "Bulgaria"
	BurkinaFaso         = "Burkina-faso"
	Burma               = "Burma"
	Burundi             = "Burundi"
	Cameroon            = "Cameroon"
	Canada              = "Canada"
	CaymanIs            = "Cayman Is."
	CentralAfricanRep   = "Central African Republic"
	Chad                = "Chad"
	Chile               = "Chile"
	China               = "China"
	Colombia            = "Colombia"
	Congo               = "Congo"
	CookIs              = "Cook Is."
	CostaRica           = "Costa Rica"
	Cuba                = "Cuba"
	Cyprus              = "Cyprus"
	CzechRep            = "Czech Republic"
	Denmark             = "Denmark"
	Djibouti            = "Djibouti"
	DominicaRep         = "Dominica Rep."
	Ecuador             = "Ecuador"
	Egypt               = "Egypt"
	EISalvador          = "EI Salvador"
	Estonia             = "Estonia"
	Ethiopia            = "Ethiopia"
	Fiji                = "Fiji"
	Finland             = "Finland"
	France              = "France"
	FrenchGuiana        = "French Guiana"
	Gabon               = "Gabon"
	Gambia              = "Gambia"
	Georgia             = "Georgia"
	Germany             = "Germany"
	Ghana               = "Ghana"
	Gibraltar           = "Gibraltar"
	Greece              = "Greece"
	Grenada             = "Grenada"
	Guam                = "Guam"
	Guatemala           = "Guatemala"
	Guinea              = "Guinea"
	Guyana              = "Guyana"
	Haiti               = "Haiti"
	Honduras            = "Honduras"
	Hongkong            = "Hongkong"
	Hungary             = "Hungary"
	Iceland             = "Iceland"
	India               = "India"
	Indonesia           = "Indonesia"
	Iran                = "Iran"
	Iraq                = "Iraq"
	Ireland             = "Ireland"
	Israel              = "Israel"
	Italy               = "Italy"
	IvoryCoast          = "Ivory Coast"
	Jamaica             = "Jamaica"
	Japan               = "Japan"
	Jordan              = "Jordan"
	Kampuchea           = "Kampuchea (Cambodia)"
	Kazakstan           = "Kazakstan"
	Kenya               = "Kenya"
	Korea               = "Korea"
	Kuwait              = "Kuwait"
	Kyrgyzstan          = "Kyrgyzstan"
	Laos                = "Laos"
	Latvia              = "Latvia"
	Lebanon             = "Lebanon"
	Lesotho             = "Lesotho"
	Liberia             = "Liberia"
	Libya               = "Libya"
	Liechtenstein       = "Liechtenstein"
	Lithuania           = "Lithuania"
	Luxembourg          = "Luxembourg"
	Macao               = "Macao"
	Madagascar          = "Madagascar"
	Malawi              = "Malawi"
	Malaysia            = "Malaysia"
	Maldives            = "Maldives"
	Mali                = "Mali"
	Malta               = "Malta"
	MarianaIs           = "Mariana Is"
	Martinique          = "Martinique"
	Mauritius           = "Mauritius"
	Mexico              = "Mexico"
	MoldovaRep          = "Republic of Moldova"
	Monaco              = "Monaco"
	Mongolia            = "Mongolia"
	MontserratIs        = "Montserrat Is"
	Morocco             = "Morocco"
	Mozambique          = "Mozambique"
	Namibia             = "Namibia"
	Nauru               = "Nauru"
	Nepal               = "Nepal"
	NetheriandsAntilles = "Netheriands Antilles"
	Netherlands         = "Netherlands"
	NewZealand          = "New Zealand"
	Nicaragua           = "Nicaragua"
	Niger               = "Niger"
	Nigeria             = "Nigeria"
	NorthKorea          = "North Korea"
	Norway              = "Norway"
	Oman                = "Oman"
	Pakistan            = "Pakistan"
	Panama              = "Panama"
	PapuaNewCuinea      = "Papua New Cuinea"
	Paraguay            = "Paraguay"
	Peru                = "Peru"
	Philippines         = "Philippines"
	Poland              = "Poland"
	FrenchPolynesia     = "French Polynesia"
	Portugal            = "Portugal"
	PuertoRico          = "Puerto Rico"
	Qatar               = "Qatar"
	Reunion             = "Reunion"
	Romania             = "Romania"
	Russia              = "Russia"
	SaintLueia          = "Saint Lueia"
	SaintVincent        = "Saint Vincent"
	SamoaEastern        = "Samoa Eastern"
	SamoaWestern        = "Samoa Western"
	SanMarino           = "San Marino"
	SaoTomePrincipe     = "Sao Tome and Principe"
	SaudiArabia         = "Saudi Arabia"
	Senegal             = "Senegal"
	Seychelles          = "Seychelles"
	SierraLeone         = "Sierra Leone"
	Singapore           = "Singapore"
	Slovakia            = "Slovakia"
	Slovenia            = "Slovenia"
	SolomonIs           = "Solomon Is"
	Somali              = "Somali"
	SouthAfrica         = "South Africa"
	Spain               = "Spain"
	SriLanka            = "Sri Lanka"
	StLucia             = "St.Lucia"
	StVincent           = "St.Vincent"
	Sudan               = "Sudan"
	Suriname            = "Suriname"
	Swaziland           = "Swaziland"
	Sweden              = "Sweden"
	Switzerland         = "Switzerland"
	Syria               = "Syria"
	Taiwan              = "Taiwan"
	Tajikstan           = "Tajikstan"
	Tanzania            = "Tanzania"
	Thailand            = "Thailand"
	Togo                = "Togo"
	Tonga               = "Tonga"
	TrinidadTobago      = "Trinidad and Tobago"
	Tunisia             = "Tunisia"
	Turkey              = "Turkey"
	Turkmenistan        = "Turkmenistan"
	Uganda              = "Uganda"
	Ukraine             = "Ukraine"
	UnitedArabEmirates  = "United Arab Emirates"
	UnitedKiongdom      = "United Kiongdom "
	USA                 = "United States of America"
	Uruguay             = "Uruguay"
	Uzbekistan          = "Uzbekistan"
	Venezuela           = "Venezuela"
	Vietnam             = "Vietnam"
	Yemen               = "Yemen"
	Yugoslavia          = "Yugoslavia"
	Zimbabwe            = "Zimbabwe"
	Zaire               = "Zaire"
	Zambia              = "Zambia"
)
View Source
const (
	WRoleSuper     = "super-admin"   // Super admin, auto add
	WRoleAdmin     = "admin"         // Normal admin, same time as super admin permissions
	WRoleUser      = "user"          // Default normal user
	WRoleMComp     = "mall-comp"     // Mall composer account
	WRoleMDesigner = "mall-designer" // Mall designer account
	WRoleSComp     = "store-comp"    // Store composer account
	WRoleSMachine  = "store-machine" // Store machine account
	WRoleQKPartner = "qk-partner"    // QKS partner account
	WRoleQKComp    = "qk-comp"       // QKS composer account
	WRoleQKMachine = "qk-machine"    // QKS machine account

)

RBAC role string

View Source
const (
	WRGroupUser     = "user"
	WRGroupAdmin    = "admin"
	WRGroupComp     = "comp"
	WRGroupDesigner = "design"
	WRGroupMachine  = "mach"
	WRGroupPartner  = "part"
)

RBAC role router keyword

View Source
const (
	StatusOK             = http.StatusOK        // success status
	StatusExError        = http.StatusAccepted  // response extend error on 202 code
	StatusBadFile        = http.StatusNoContent // response file unsaved on 204 code
	E400ParseParams      = http.StatusBadRequest
	E401Unauthorized     = http.StatusUnauthorized
	E403PermissionDenied = http.StatusForbidden
	E404Exception        = http.StatusNotFound
	E405FuncDisabled     = http.StatusMethodNotAllowed
	E406InputParams      = http.StatusNotAcceptable
	E408Timeout          = http.StatusRequestTimeout
	E409Duplicate        = http.StatusConflict
	E410Gone             = http.StatusGone
	E412InvalidState     = http.StatusPreconditionFailed
	E423Locked           = http.StatusLocked
	E426UpgradeRequired  = http.StatusUpgradeRequired
)
View Source
const (
	// StatusSuccess            [0],status success
	StatusSuccess byte = iota

	// StatusInternalErr        [1],status internal error
	StatusInternalErr

	// StatusBadSecret          [2],status bad secret
	StatusBadSecret

	// StatusFullConnectionPool [3],status full connection pool
	StatusFullConnectionPool

	// StatusFullConnectionPool [4],status instance id exist
	StatusInstanceIdExist
)

Frame's status type

View Source
const PayeeDunYu = "PAYEE_DUNYU"

Fixed target payee for all trade of DY

View Source
const TSClosed = "CLOSED"

Closed state, as the last state of status machine.

View Source
const TSCompleted = "COMPLETED"

Completed all dividing payments, as status machine it only can be changed to closed state :

TSCompleted	 -> TSClosed : close the trade ticket
View Source
const TSInProgress = "REFUND_IN_PROGRESS"

Refund in progress state, use as default trade state when generate a refund ticket, as status machine it can change to :

TSInProgress -> TSRefund      : success refund
			 -> TSRefundError : refund error
View Source
const TSPaid = "PAID"

Paied success state, as status machine it only can be changed to closed state :

TSPaid		 -> TSClosed : close the trade ticket

`WARNING` :

the refund action will generate a new trade ticket and set TSInProgress as default.

View Source
const TSPayError = "PAY_ERROR"

Pay error state, as status machine it can change to :

TSPayError	 -> TSPaid    : success paid
			 -> TSRevoked : canceld parment
			 -> self (over 5 times) -> TSClosed
View Source
const TSRefund = "REFUND"

Refund success state, as status machine it only can be changed to closed state :

TSRefund	 -> TSClosed : close the trade ticket
View Source
const TSRefundError = "REFUND_ERROR"

Refund success state, as status machine it only can be changed to closed state :

TSRefundError	-> TSClosed : close the trade ticket
				-> self (over 5 times) -> TSClosed
View Source
const TSRevoked = "REVOKED"

Revoked state, cancel by user, as status machine it only can be changed to closed state:

TSRevoked	 -> TSClosed : close the trade ticket
View Source
const TSUnpaid = "UNPAID"

Unpid state, can be use as default trade state for generate a trade ticket, as status machine it can change to :

TSUnpaid	 -> TSRevoked   : canceld parment
			 -> TSPayError  : pay error
			 -> TSPaid      : success paid
			 -> TSCompleted : only for dividing payment, to mark dividing completed

Variables

View Source
var (
	ErrNotFound            = WingErr{errors.New("not fount"), 0x1000}
	ErrInvalidNum          = WingErr{errors.New("invalid number"), 0x1001}
	ErrInvalidAccount      = WingErr{errors.New("invalid account"), 0x1002}
	ErrInvalidToken        = WingErr{errors.New("invalid token"), 0x1003}
	ErrInvalidRole         = WingErr{errors.New("invalid role"), 0x1004}
	ErrInvalidClient       = WingErr{errors.New("invalid client"), 0x1005}
	ErrInvalidDevice       = WingErr{errors.New("invalid device"), 0x1006}
	ErrInvalidParams       = WingErr{errors.New("invalid params"), 0x1007}
	ErrInvalidData         = WingErr{errors.New("invalid data"), 0x1008}
	ErrInvalidState        = WingErr{errors.New("invalid state"), 0x1009}
	ErrInvalidPhone        = WingErr{errors.New("invalid phone"), 0x100A}
	ErrInvalidEmail        = WingErr{errors.New("invalid email"), 0x100B}
	ErrInvalidOptions      = WingErr{errors.New("invalid options"), 0x100C}
	ErrInvalidRedisOptions = WingErr{errors.New("invalid redis options"), 0x100D}
	ErrInvalidConfigs      = WingErr{errors.New("invalid config datas"), 0x100E}
	ErrInvaildExecTime     = WingErr{errors.New("invaild execute time"), 0x100F}
	ErrInvalidRealname     = WingErr{errors.New("invaild realname"), 0x1010}
	ErrTagOffline          = WingErr{errors.New("target offline"), 0x1011}
	ErrClientOffline       = WingErr{errors.New("client offline"), 0x1012}
	ErrDupRegister         = WingErr{errors.New("duplicated registration"), 0x1013}
	ErrDupLogin            = WingErr{errors.New("duplicated admin login"), 0x1014}
	ErrDupData             = WingErr{errors.New("duplicated data"), 0x1015}
	ErrDupAccount          = WingErr{errors.New("duplicated account"), 0x1016}
	ErrDupName             = WingErr{errors.New("duplicate name"), 0x1017}
	ErrDupKey              = WingErr{errors.New("duplicate key"), 0x1018}
	ErrTokenExpired        = WingErr{errors.New("token expired"), 0x1019}
	ErrBadPublicKey        = WingErr{errors.New("invalid public key"), 0x101A}
	ErrBadPrivateKey       = WingErr{errors.New("invalid private key"), 0x101B}
	ErrUnkownCharType      = WingErr{errors.New("unkown chars type"), 0x101C}
	ErrUnperparedState     = WingErr{errors.New("unperpared state"), 0x101D}
	ErrOrmNotUsing         = WingErr{errors.New("orm not using"), 0x101E}
	ErrNoneRowFound        = WingErr{errors.New("none row found"), 0x101F}
	ErrNotChanged          = WingErr{errors.New("not changed"), 0x1020}
	ErrNotInserted         = WingErr{errors.New("not inserted"), 0x1021}
	ErrSendFailed          = WingErr{errors.New("failed to send"), 0x1022}
	ErrAuthDenied          = WingErr{errors.New("permission denied"), 0x1023}
	ErrKeyLenSixteen       = WingErr{errors.New("require sixteen-length secret key"), 0x1024}
	ErrOverTimes           = WingErr{errors.New("over retry times"), 0x1025}
	ErrSetFrameNil         = WingErr{errors.New("failed clear frame meta"), 0x1026}
	ErrOperationNotSupport = WingErr{errors.New("operation not support"), 0x1027}
	ErrSendHeadBytes       = WingErr{errors.New("failed send head bytes"), 0x1028}
	ErrSendBodyBytes       = WingErr{errors.New("failed send body bytes"), 0x1029}
	ErrReadBytes           = WingErr{errors.New("error read bytes"), 0x102A}
	ErrInternalServer      = WingErr{errors.New("internal server error"), 0x102B}
	ErrCreateByte          = WingErr{errors.New("failed create bytes: system protection"), 0x102C}
	ErrFileNotFound        = WingErr{errors.New("file not found"), 0x102D}
	ErrDownloadFile        = WingErr{errors.New("failed download file"), 0x102E}
	ErrOpenSourceFile      = WingErr{errors.New("failed open source file"), 0x102F}
	ErrAlreadyConn         = WingErr{errors.New("already connected"), 0x1030}
	ErrEmptyReponse        = WingErr{errors.New("received empty response"), 0x1031}
	ErrReadConf            = WingErr{errors.New("failed load config file"), 0x1032}
	ErrUnexpectedDir       = WingErr{errors.New("expect file path not directory"), 0x1033}
	ErrWriteMD5            = WingErr{errors.New("failed write to md5"), 0x1034}
	ErrWriteOut            = WingErr{errors.New("failed write out"), 0x1035}
	ErrHandleDownload      = WingErr{errors.New("failed handle download file"), 0x1036}
	ErrFullConnPool        = WingErr{errors.New("connection pool is full"), 0x1037}
	ErrPoolSize            = WingErr{errors.New("thread pool size value must be positive"), 0x1038}
	ErrPoolFull            = WingErr{errors.New("pool is full, can not take any more"), 0x1039}
	ErrCheckDB             = WingErr{errors.New("check database: failed retry many times"), 0x103A}
	ErrFetchDB             = WingErr{errors.New("fetch database connection timeout"), 0x103B}
	ErrReadFileBody        = WingErr{errors.New("failed read file content"), 0x103C}
	ErrNilFrame            = WingErr{errors.New("frame is null"), 0x103D}
	ErrNoStorage           = WingErr{errors.New("no storage server available"), 0x103E}
	ErrUnmatchLen          = WingErr{errors.New("unmatch download file length"), 0x103F}
	ErrCopyFile            = WingErr{errors.New("failed copy file"), 0x1040}
	ErrEmptyData           = WingErr{errors.New("empty data"), 0x1041}
	ErrImgOverSize         = WingErr{errors.New("image file size over"), 0x1042}
	ErrAudioOverSize       = WingErr{errors.New("audio file size over"), 0x1043}
	ErrVideoOverSize       = WingErr{errors.New("video file size over"), 0x1044}
	ErrNoAssociatedExpire  = WingErr{errors.New("no associated expire"), 0x1045}
	ErrUnsupportFormat     = WingErr{errors.New("unsupported format data"), 0x1046}
	ErrUnsupportedFile     = WingErr{errors.New("unsupported file format"), 0x1047}
	ErrUnexistKey          = WingErr{errors.New("unexist key"), 0x1048}
	ErrUnexistRedisKey     = WingErr{errors.New("unexist redis key"), 0x1049}
	ErrUnexistLifecycle    = WingErr{errors.New("unexist lifecycle configs"), 0x104A}
	ErrSetLifecycleTag     = WingErr{errors.New("failed set file lifecycle tag"), 0x104B}
	ErrInactiveAccount     = WingErr{errors.New("inactive status account"), 0x104C}
	ErrCaseException       = WingErr{errors.New("case exception"), 0x104D}
)

Functions

func AddWebMimeType

func AddWebMimeType(format string)

AddWebMimeType add web content file format based on mimeTypes

func AppendLangs

func AppendLangs(langs string, code int) string

AppendLangs append a language key to multi-language string

func EnableMimeTypes

func EnableMimeTypes()

EnableMimeTypes endable and init mime type map, by default it is disabled. if enable it will auto add download header 'Content-Type' before download, or set download header 'Content-Type' to 'application/octet-stream' when disabled.

func EqualError

func EqualError(a, b error) bool

Equal tow error if message same on char case

func EqualErrorFold

func EqualErrorFold(a, b error) bool

Equal tow error if message same ignoral char case

func ErrorContain

func ErrorContain(s, sub error) bool

Check if error message contain given error string

func ErrorEnd

func ErrorEnd(s, sub error) bool

Check if error message start given perfix

func ErrorStart

func ErrorStart(s, sub error) bool

Check if error message start given perfix

func GetContentType

func GetContentType(fileFormat string) *string

GetContentType get mime type by file ext

func GetLangCode

func GetLangCode(key string) int

GetLangCode get language code by key

func GetRouterKey

func GetRouterKey(role string) string

Return role router key by given role, it maybe just return role string when not found from defined roles

func IsContain

func IsContain(langs string, code int) bool

IsContain check the language if exist in multi-language string

func IsDupError

func IsDupError(e error) bool

Check given error if duplicated errors

func IsError

func IsError(e error, s string) bool

Check if error message contain given string

func IsValidAdmin

func IsValidAdmin(role string) bool

Check given role if super or admin role

func IsValidLang

func IsValidLang(code int) bool

IsValidLang check the given language code if valid

func IsValidUser

func IsValidUser(role string) bool

Check given role if normal user, not admins

func PushDomain

func PushDomain(origin string)

PushDomain push allowed domain on list back

func RegexASCII

func RegexASCII(src string) bool

func RegexAlpha

func RegexAlpha(src string) bool

func RegexAlphaNumeric

func RegexAlphaNumeric(src string) bool

func RegexAlphaUnicode

func RegexAlphaUnicode(src string) bool

func RegexAlphaUnicodeNumeric

func RegexAlphaUnicodeNumeric(src string) bool

func RegexBase64

func RegexBase64(src string) bool

func RegexBase64URL

func RegexBase64URL(src string) bool

func RegexBic

func RegexBic(src string) bool

func RegexBtcAddress

func RegexBtcAddress(src string) bool

func RegexBtcLowerAddressBech32

func RegexBtcLowerAddressBech32(src string) bool

func RegexBtcUpperAddressBech32

func RegexBtcUpperAddressBech32(src string) bool

func RegexDataURI

func RegexDataURI(src string) bool

func RegexDnsRFC1035Label

func RegexDnsRFC1035Label(src string) bool

func RegexE164

func RegexE164(src string) bool

func RegexEmail

func RegexEmail(src string) bool

func RegexEthAddress

func RegexEthAddress(src string) bool

func RegexEthAddressLower

func RegexEthAddressLower(src string) bool

func RegexEthAddressUpper

func RegexEthAddressUpper(src string) bool

func RegexFqdnRFC1123

func RegexFqdnRFC1123(src string) bool

func RegexHTML

func RegexHTML(src string) bool

func RegexHTMLEncoded

func RegexHTMLEncoded(src string) bool

func RegexHexColor

func RegexHexColor(src string) bool

func RegexHexadecimal

func RegexHexadecimal(src string) bool

func RegexHostRFC1123

func RegexHostRFC1123(src string) bool

func RegexHostRFC952

func RegexHostRFC952(src string) bool

func RegexHsl

func RegexHsl(src string) bool

func RegexHsla

func RegexHsla(src string) bool

func RegexISBN10

func RegexISBN10(src string) bool

func RegexISBN13

func RegexISBN13(src string) bool

func RegexJWT

func RegexJWT(src string) bool

func RegexLatitude

func RegexLatitude(src string) bool

func RegexLongitude

func RegexLongitude(src string) bool

func RegexMd4

func RegexMd4(src string) bool

func RegexMd5

func RegexMd5(src string) bool

func RegexMultibyte

func RegexMultibyte(src string) bool

func RegexNumber

func RegexNumber(src string) bool

func RegexNumeric

func RegexNumeric(src string) bool

func RegexPrintableASCII

func RegexPrintableASCII(src string) bool

func RegexRgb

func RegexRgb(src string) bool

func RegexRgba

func RegexRgba(src string) bool

func RegexRipemd128

func RegexRipemd128(src string) bool

func RegexRipemd160

func RegexRipemd160(src string) bool

func RegexSSN

func RegexSSN(src string) bool

func RegexSemver

func RegexSemver(src string) bool

func RegexSha256

func RegexSha256(src string) bool

func RegexSha384

func RegexSha384(src string) bool

func RegexSha512

func RegexSha512(src string) bool

func RegexSplitParams

func RegexSplitParams(src string) bool

func RegexTiger128

func RegexTiger128(src string) bool

func RegexTiger160

func RegexTiger160(src string) bool

func RegexTiger192

func RegexTiger192(src string) bool

func RegexULID

func RegexULID(src string) bool

func RegexURLEncoded

func RegexURLEncoded(src string) bool

func RegexUUID

func RegexUUID(src string) bool

func RegexUUID3

func RegexUUID3(src string) bool

func RegexUUID3RFC4122

func RegexUUID3RFC4122(src string) bool

func RegexUUID4

func RegexUUID4(src string) bool

func RegexUUID4RFC4122

func RegexUUID4RFC4122(src string) bool

func RegexUUID5

func RegexUUID5(src string) bool

func RegexUUID5RFC4122

func RegexUUID5RFC4122(src string) bool

func RegexUUIDRFC4122

func RegexUUIDRFC4122(src string) bool

func RemoveLangs

func RemoveLangs(langs string, code int) string

RemoveLangs remove a language key outof multi-language string

func StatusText

func StatusText(code int) string

StatusText returns a text for the HTTP status code, It returns the empty string if the code is unknown.

func ViaDomain

func ViaDomain(referer string) bool

ViaDomain verify whether referer is allowed

func ViaWebContent

func ViaWebContent(ext string) bool

ViaWebContent verfiy whether ext is support web content

Types

type Bool

type Bool int

Bool boolean type

const (
	// BFalse mean false or FALSE
	BFalse Bool = iota - 1

	// BNone means default status, not inited
	BNone

	// BTrue means true or TRUE
	BTrue
)

type Box

type Box int

Box box type

const (
	// BoxDraft     [0], draft box
	BoxDraft Box = iota

	// BoxActive    [1], active box
	BoxActive

	// BoxOffShelve [2], offshelve box
	BoxOffShelve

	// BoxSend      [3], send box
	BoxSend

	// BoxReceive   [4], receive box
	BoxReceive

	// BoxSending   [5], sending box
	BoxSending

	// BoxDustbin   [6], dustbin box
	BoxDustbin
)

The BoxDraft must be 0 that set in database initialize script, if you want change it, plase modify script together

type Kind

type Kind int

King category type

const (
	// KindHome    [0], home kind
	KindHome Kind = iota

	// KindCompany [1], company kind
	KindCompany

	// KindOthers  [2], others kind
	KindOthers
)

type Lang

type Lang struct {
	Key    string // Language unique key
	EnName string // Language english name
	CnName string // Language chinese name
	// contains filtered or unexported fields
}

Language language information

func GetLanguage

func GetLanguage(code int) *Lang

GetLanguage get language information by code

type Limit

type Limit int

Limit limit permission type

const (
	// LimitAddible   [0], addible permission
	LimitAddible Limit = iota

	// LimitMutable   [1], mutable permission
	LimitMutable

	// LimitPayable   [2], payable permission
	LimitPayable

	// LimitSettable  [3], settable permission
	LimitSettable

	// LimitDeletable [4], deletable permission
	LimitDeletable
)

type Region

type Region struct {
	Phone    string // Phone region number
	TimeDiff string // Region timezoom diff
	CnName   string // Contry chinese name
	// contains filtered or unexported fields
}

Region regions data

func GetRegion

func GetRegion(country string) *Region

GetRegion get region information by country

func GetRegionByCode

func GetRegionByCode(code string, phone ...string) (string, *Region)

GetRegionByCode get country and region information by code and phone

type Role

type Role int

Role role type

const (
	// RoleUser      [ 0], user role
	RoleUser Role = iota

	// RoleAdmin     [ 1], admin role
	RoleAdmin

	// RoleManager   [ 2], manager role
	RoleManager

	// RoleSuper     [ 3], super role
	RoleSuper

	// RoleConsumer  [ 4], consumer role
	RoleConsumer

	// RoleSeller    [ 5], seller role
	RoleSeller

	// RoleAgent     [ 6], agent role
	RoleAgent

	// RoleVendor    [ 7], vendor role
	RoleVendor

	// RoleOwner     [ 8], owner role
	RoleOwner

	// RoleTarget    [ 9], target role
	RoleTarget

	// RoleGuest     [10], user role
	RoleGuest

	// RoleMaster    [11], user role
	RoleMaster

	// RoleCaller    [12], caller role
	RoleCaller

	// RoleCallee    [13], callee role
	RoleCallee

	// RoleReception [14], company reception role
	RoleReception

	// RoleControl   [15], control room role
	RoleControl

	// RoleRoom      [16], gurst room role
	RoleRoom
)

type Status

type Status int

Status status type

const (
	// StatePanic     [-5], panic state
	StatePanic Status = iota - 5

	// StateException [-4], exception state
	StateException

	// StateTimeout   [-3], failed state
	StateTimeout

	// StateFailed    [-2], failed state
	StateFailed

	// StateError     [-1], error state
	StateError

	// StateSuccess   [ 0], success state
	StateSuccess

	// StateRecover   [ 1], recover state
	StateRecover
)
const (
	// StateActive   [0], activate state
	StateActive Status = iota

	// StateFrozen   [1], frozen state
	StateFrozen

	// StateDisabled [2], disable state
	StateDisabled
)

The StaActivate value must be 0 that set in database initialize script, if you want change it, plase modify script together

const (
	// StateUnpaied [0], initialization state when trade just created
	StateUnpaid Status = iota

	// StatePaid    [1], the transaction completed
	StatePaid

	// StateExpired [2], the transaction expired
	StateExpired

	// StateFailure [3], the transaction failed
	StateFailure
)

The StateUnpaid value must be 0 that set in database initialize script, if you want change it, plase modify script together

type WExErr

type WExErr struct {
	Code    int    `json:"code"    description:"Extend error code"`
	Message string `json:"message" description:"Extend error message"`
}

WExErr extend error with code and error message

func ExErr

func ExErr(code int, message string) *WExErr

Create a WExErr from given code and message

func StErr

func StErr(code int, message string) (int, *WExErr)

Create a WExErr from given code and message

type WingErr

type WingErr struct {
	Code int // Extend error code, start 0x1000
	// contains filtered or unexported fields
}

WingErr constom error with code

func WErr

func WErr(code int, message string) *WingErr

Create a WingErr from given code and message

func (*WingErr) Err

func (w *WingErr) Err() error

Return standry error from WingErr object.

// Simple to get standry error object
var err error
err = invar.ErrNotFoune.Err()

func (*WingErr) ExErr

func (w *WingErr) ExErr() *WExErr

Return WExErr extend error from WingErr object.

// Simple to get WExErr extend error
var exerr *invar.WExErr
exerr = invar.ErrNotFoune.ExErr()

// Directly using WingErr as error value
var err error
err := invar.ErrNotFoune

func (*WingErr) StErr

func (w *WingErr) StErr() (int, *WExErr)

Return HTTP response code and WExErr extend error.

// Using for Restful API to response custom status and message.
http_resp_code, err := invar.ErrNotFoune.StErr()

Jump to

Keyboard shortcuts

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