smartgo

package module
v0.0.0-...-642df0c Latest Latest
Warning

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

Go to latest
Published: Jan 14, 2024 License: BSD-3-Clause Imports: 78 Imported by: 11

README

smartgo

GO Module for Smart.Framework

Documentation

Overview

REQUIRE: go 1.19 or later

REQUIRE: go 1.19 or later

REQUIRE: go 1.19 or later

REQUIRE: go 1.19 or later

REQUIRE: go 1.19 or later

REQUIRE: go 1.19 or later

REQUIRE: go 1.19 or later

REQUIRE: go 1.19 or later

REQUIRE: go 1.19 or later

REQUIRE: go 1.19 or later (depends on Go generics, available since go 1.18 but real stable since go 1.19)

Index

Constants

View Source
const (
	SEPARATOR_SFZ_CHECKSUM_V1 string = "#CHECKSUM-SHA1#" // compatibility, v1
	SEPARATOR_SFZ_CHECKSUM_V2 string = "#CKSUM256#"      // compatibility, v2
	SEPARATOR_SFZ_CHECKSUM_V3 string = "#CKSUM384V3#"    // current, v3

	SIGNATURE_SFZ_DATA_ARCH_V1 string = "PHP.SF.151129/B64.ZLibRaw.HEX"  // compatibility, v1, unarchive only
	SIGNATURE_SFZ_DATA_ARCH_V2 string = "SFZ.20210818/B64.ZLibRaw.hex"   // compatibility, v2, unarchive only
	SIGNATURE_SFZ_DATA_ARCH_V3 string = "[SFZ.20231031/B64.ZLibRaw.hex]" // current, v3 ; archive + unarchive
)
View Source
const (
	ALGO_PASS_SMART_SAFE_PASS       uint8 = 0
	ALGO_PASS_SMART_SAFE_ARGON_PASS uint8 = 1

	HTTP_AUTH_MODE_NONE   uint8 = 0
	HTTP_AUTH_MODE_BASIC  uint8 = 1
	HTTP_AUTH_MODE_BEARER uint8 = 2
	HTTP_AUTH_MODE_COOKIE uint8 = 3

	REGEX_SAFE_HTTP_USER_NAME string = `^[a-z0-9\.]+$` // Safe UserName Regex
)
View Source
const (
	SEPARATOR_CRYPTO_CHECKSUM_V1 string = "#CHECKSUM-SHA1#" // compatibility, v1 ; blowfish only
	SEPARATOR_CRYPTO_CHECKSUM_V2 string = "#CKSUM256#"      // compatibility, v2 ; blowfish only
	SEPARATOR_CRYPTO_CHECKSUM_V3 string = "#CKSUM512V3#"    // current, v3 ; threefish, twofish, blowfish

	SIGNATURE_BFISH_V1 string = "bf384.v1!" // compatibility, v1 ; decrypt only
	SIGNATURE_BFISH_V2 string = "bf448.v2!" // compatibility, v2 ; decrypt only
	SIGNATURE_BFISH_V3 string = "bf448.v3!" // current, v3 ; encrypt + decrypt

	SIGNATURE_2FISH_V1_DEFAULT    string = "2f256.v1!" // current, v1 (default)   ; encrypt + decrypt
	SIGNATURE_2FISH_V1_BF_DEFAULT string = "2fb88.v1!" // current, v1 (default+blowfish) ; encrypt + decrypt ; Blowfish 56 (448) + TwoFish 32 (256) = 88 (704)

	SIGNATURE_3FISH_1K_V1_DEFAULT  string = "3f1kD.v1!" // current, v1 1024 (default)  ; encrypt + decrypt
	SIGNATURE_3FISH_1K_V1_ARGON2ID string = "3f1kA.v1!" // current, v1 1024 (argon2id) ; encrypt + decrypt

	SIGNATURE_3FISH_1K_V1_2FBF_D string = "3ffb2kD.v1!" // current, v1 1024 (default+twofish/256+blowfish/448)  ; encrypt + decrypt
	SIGNATURE_3FISH_1K_V1_2FBF_A string = "3ffb2kA.v1!" // current, v1 1024 (argon2id+twofish/256+blowfish/448) ; encrypt + decrypt

	SALT_PREFIX    string = "Smart Framework" // fixed salt prefix
	SALT_SEPARATOR string = "#"               // fixed salt separator
	SALT_SUFFIX    string = "スマート フレームワーク"    // fixed salt suffix

	DERIVE_MIN_KLEN    uint16 = 3    // Key Derive Min Length
	DERIVE_MAX_KLEN    uint16 = 4096 // Key Derive Min Length
	DERIVE_PREKEY_LEN  uint16 = 80   // Key Derive Pre-Key Length
	DERIVE_CENTITER_EK uint16 = 87   // Key Derive EK Iterations
	DERIVE_CENTITER_EV uint16 = 78   // Key Derive EV Iterations
	DERIVE_CENTITER_PW uint16 = 77   // Key Derive PW Iterations

	PASSWORD_PLAIN_MIN_LENGTH    uint8  = 7          // Password Plain Min Lentgth
	PASSWORD_PLAIN_MAX_LENGTH    uint8  = 55         // Password Plain Max Lentgth
	PASSWORD_HASH_LENGTH         uint8  = 128        // fixed length ; {{{SYNC-AUTHADM-PASS-LENGTH}}} ; if lower then padd to right with * ; {{{SYNC-AUTHADM-PASS-PADD}}}
	PASSWORD_PREFIX_VERSION      string = "$fPv3.7!" // {{{SYNC-AUTHADM-PASS-PREFIX}}}
	PASSWORD_PREFIX_A2ID_VERSION string = "a2idP37!" // go lang only (no PHP), curent v3, argon2id password ; must be the same length as PASSWORD_PREFIX_VERSION
)
View Source
const (
	//-- FIXED DATE CONSTANTS REFERENCE VALUES ... SYNCED WITH GO DATE STANDARDS !
	DATE_TIME_DEFAULT_LOCAL_TIMEZONE  string = "UTC"
	DATE_TIME_FMT_ISO_NOTIME_GO_EPOCH string = "2006-01-02"                // GO EPOCH:   NO TIME,   NO TZ OFFSET
	DATE_TIME_FMT_ISO_STD_GO_EPOCH    string = "2006-01-02 15:04:05"       // GO EPOCH: WITH TIME,   NO TZ OFFSET
	DATE_TIME_FMT_ISO_TZOFS_GO_EPOCH  string = "2006-01-02 15:04:05 -0700" // GO EPOCH: WITH TIME, WITH TZ OFFSET
	DATE_TIME_FMT_RFC1123_GO_EPOCH    string = "Mon, 02 Jan 2006 15:04:05" // GO EPOCH: RFC1123

)
View Source
const (
	CHOWN_DIRS  os.FileMode = 0755
	CHOWN_FILES os.FileMode = 0644

	//-- Cross Platform Safe Paths ; The following ars disallowed in Windows paths: `< > : " / \ | ? *` ; also disallow SPACE because of the web context
	REGEX_SAFE_PATH_NAME string = `^[_a-zA-Z0-9\-\.@#\/` + "`" + `~\!\$%&\(\)\^\{\}'` + `\[\],;+` + `]+$` // SAFETY: SAFE Cross Platform Character Set for FileSystems: Smart + MsDOS + Linux/Unix + Windows (intersect)
	REGEX_SAFE_FILE_NAME string = `^[_a-zA-Z0-9\-\.@#` + "`" + `~\!\$%&\(\)\^\{\}'` + `\[\],;+` + `]+$`   // SAFETY: SAFE Cross Platform Character Set for FileSystems: Smart + MsDOS + Linux/Unix + Windows (intersect) ; like above, just missing slash /

	//-- Web Ultra-Safe Paths (Smart)
	REGEX_SMART_SAFE_PATH_NAME string = `^[_a-zA-Z0-9\-\.@#\/]+$` // SAFETY: SUPPORT ONLY THESE CHARACTERS IN FILE SYSTEM PATHS ...
	REGEX_SMART_SAFE_FILE_NAME string = `^[_a-zA-Z0-9\-\.@#]+$`   // SAFETY: SUPPORT ONLY THESE CHARACTERS IN FILE SYSTEM FILE AND DIR NAMES ... ; like above, just missing slash /

	INVALID_ABSOLUTE_PATH string = "/tmp/err-absolute-path/invalid-path/"
)
View Source
const (
	REGEX_SMART_SAFE_BASE_PATH string = `^[_a-z0-9\-\/]+$` // CONFORMANCE: SUPPORT ONLY THESE CHARACTERS IN HTML BASE PATHS

	REGEX_SMART_SAFE_NET_HOSTNAME    string = `^[_a-z0-9\-\.]+$` // SAFETY: SUPPORT ONLY THESE CHARACTERS IN NET HOST NAMES AS RFC ; if a hostname have upper characters must be converted to all lower characters ; if a hostname have unicode characters must be converted using punnycode ...
	REGEX_SMART_SAFE_HTTP_HEADER_KEY string = `^[A-Za-z0-9\-]+$` // SAFETY: SUPPORT ONLY THESE CHARACTERS IN HEADER KEY VALUES

	HTTP_PROTO_PREFIX_HTTP  string = "http://"
	HTTP_PROTO_PREFIX_HTTPS string = "https://"

	DEFAULT_FAKE_IP_CLIENT       string = "0.0.0.0"
	DEFAULT_FAKE_HOSTPORT_SERVER string = "256.256.256.256:65535"
)
View Source
const (
	SPECIAL_TRIM string = "\n\r\x00\x0B"

	UNDEF_VAR_NAME string = "Undef____V_a_r"
)
View Source
const (
	VERSION string = "v.20240114.2007"
	NAME    string = "SmartGo"

	DESCRIPTION string = "Smart.Framework.Go"
	COPYRIGHT   string = "(c) 2021-2024 unix-world.org"

	CHARSET string = "UTF-8" // don't change !!

	REGEX_SAFE_APP_NAMESPACE      string = `^[_a-z0-9\-\.]+$` // Safe App Namespace Regex
	REGEX_SMART_SAFE_NUMBER_FLOAT string = `^[0-9\-\.]+$`     // SAFETY: SUPPORT ONLY THESE CHARACTERS IN SAFE FLOAT (ex: JSON)
	REGEX_SAFE_VAR_NAME           string = `^[_a-zA-Z0-9]+$`  // Safe VarName Regex

	REGEXP2_DEFAULT_MAX_RECURSION uint32 = 800000 // Default REGEXP2 Recursion Limit: 800K
	REGEXP2_DEFAULT_MAX_TIMEOUT   uint8  = 1      // Default REGEXP2 Max Timeout 1 Second(s)

	TRIM_WHITESPACES string = " \t\n\r\x00\x0B" // PHP COMPATIBILITY

	NULL_BYTE    string = "\x00" // THE NULL BYTE character \x00 or \000
	BACK_SPACE   string = "\b"   // The Backspace Character \b
	ASCII_BELL   string = "\a"   // The ASCII Bell Character \a
	FORM_FEED    string = "\f"   // The Form Feed Character \f or \x0C
	VERTICAL_TAB string = "\v"   // The Vertical Tab character \v or \x0B

	HORIZONTAL_TAB  string = "\t" // The Horizontal Tab character \t
	LINE_FEED       string = "\n" // The Line Feed character \n
	CARRIAGE_RETURN string = "\r" // The Carriage Return character \r

	SIZE_BYTES_16M uint64 = 16777216 // Reference Unit
)
View Source
const (
	CMD_EXEC_HAMMER_SIGNATURE string = "[»»»»»»»[SmartGo:{!HAMMER!}:Abort:(Exit):KILL.SIGNAL]«««««««]" // INTERNAL FLAG FOR CMD FORCE EXIT HAMMER
)

Variables

View Source
var (
	DEBUG bool = false
)

Functions

func AddCSlashes

func AddCSlashes(s string, c string) string

func AppGetNamespace

func AppGetNamespace() (string, error)

func AppGetRunInBackground

func AppGetRunInBackground() bool

func AppSetNamespace

func AppSetNamespace(ns string) bool

func AppSetRunInBackground

func AppSetRunInBackground() bool

func ArrMapKeyExists

func ArrMapKeyExists[E comparable](v E, arr map[E]E) bool

func Auth2FACookieIsEnabled

func Auth2FACookieIsEnabled() bool

func Auth2FACookieNameGet

func Auth2FACookieNameGet() string

func Auth2FACookieNameSet

func Auth2FACookieNameSet(cookieName string) bool

func AuthBasicIsEnabled

func AuthBasicIsEnabled() bool

func AuthBasicModeSet

func AuthBasicModeSet(mode bool) bool

func AuthBearerIsEnabled

func AuthBearerIsEnabled() bool

func AuthBearerModeSet

func AuthBearerModeSet(mode bool) bool

func AuthCookieIsEnabled

func AuthCookieIsEnabled() bool

func AuthCookieNameGet

func AuthCookieNameGet() string

func AuthCookieNameSet

func AuthCookieNameSet(cookieName string) bool

func Base64Decode

func Base64Decode(data string) string

func Base64Encode

func Base64Encode(data string) string

func Base64ToBase64s

func Base64ToBase64s(data string) string

func Base64sDecode

func Base64sDecode(data string) string

func Base64sEncode

func Base64sEncode(data string) string

func Base64sToBase64

func Base64sToBase64(data string) string

func BaseDecode

func BaseDecode(data string, fromBase string) []byte

func BaseEncode

func BaseEncode(data []byte, toBase string) string

func Bin2Hex

func Bin2Hex(str string) string

func BlowfishDecryptCBC

func BlowfishDecryptCBC(str string, key string) string

func BlowfishEncryptCBC

func BlowfishEncryptCBC(str string, key string) string

func CipherDecryptCBC

func CipherDecryptCBC(algo string, str string, key string, iv string, tweak string) (string, error)

IMPORTANT: the output must be trimmed for the padding added when encrypted ; expects B64 data, so trim is OK !

func CipherEncryptCBC

func CipherEncryptCBC(algo string, str string, key string, iv string, tweak string) (string, error)

IMPORTANT: the input will be padded ; expects B64 data !

func ClearPrintTerminal

func ClearPrintTerminal()

set terminal theme Dark (bg:black ; fg:white) : print("\033[0;37;40m")

func ConvertFloat32ToStr

func ConvertFloat32ToStr(f float32) string

func ConvertFloat64ToStr

func ConvertFloat64ToStr(f float64) string

func ConvertInt16ToStr

func ConvertInt16ToStr(i int16) string

func ConvertInt32ToStr

func ConvertInt32ToStr(i int32) string

func ConvertInt64ToStr

func ConvertInt64ToStr(i int64) string

func ConvertInt8ToStr

func ConvertInt8ToStr(i int8) string

func ConvertIntToStr

func ConvertIntToStr(i int) string

func ConvertJsonNumberToStr

func ConvertJsonNumberToStr(data interface{}) string

func ConvertUInt16ToStr

func ConvertUInt16ToStr(i uint16) string

func ConvertUInt32ToStr

func ConvertUInt32ToStr(i uint32) string

func ConvertUInt64ToStr

func ConvertUInt64ToStr(i uint64) string

func ConvertUInt8ToStr

func ConvertUInt8ToStr(i uint8) string

func ConvertUIntToStr

func ConvertUIntToStr(i uint) string

func Crc32b

func Crc32b(str string) string

func Crc32bB36

func Crc32bB36(str string) string

func CryptoGetSecurityKey

func CryptoGetSecurityKey() (string, error)

func CryptoSetSecurityKey

func CryptoSetSecurityKey(key string) bool

func CurrentFunctionName

func CurrentFunctionName() string

func DataArchive

func DataArchive(str string) string

func DataRRot13

func DataRRot13(s string) string

func DataRot13

func DataRot13(s string) string

func DataUnArchive

func DataUnArchive(str string) string

func DateNowIsoLocal

func DateNowIsoLocal() string

func DateNowIsoUtc

func DateNowIsoUtc() string

func DateNowLocal

func DateNowLocal() string

func DateNowUtc

func DateNowUtc() string

func DateTimeGetLocation

func DateTimeGetLocation() string

func DateTimeSetLocation

func DateTimeSetLocation(loc string) bool

func DateTimeStructLocal

func DateTimeStructLocal(dateIsoStr string) uxmDateTimeStruct

func DateTimeStructUtc

func DateTimeStructUtc(dateIsoStr string) uxmDateTimeStruct

func EscapeCss

func EscapeCss(s string) string

func EscapeHtml

func EscapeHtml(s string) string

func EscapeJs

func EscapeJs(in string) string

func EscapeUrl

func EscapeUrl(s string) string

func EscapeXml

func EscapeXml(s string) string

func ExecCmd

func ExecCmd(captureStdout string, captureStderr string, additionalEnv string, inputStdin string, theExe string, theArgs ...string) (isSuccess bool, outStd string, errStd string)

func ExecTimedCmd

func ExecTimedCmd(stopTimeout uint, captureStdout string, captureStderr string, additionalEnv string, inputStdin string, theExe string, theArgs ...string) (isSuccess bool, outStd string, errStd string)

func Explode

func Explode(delimiter string, text string) []string

func ExplodeWithLimit

func ExplodeWithLimit(delimiter string, text string, limit int) []string

func FatalError

func FatalError(logMessages ...any)

func FatalError(logMessages ...interface{}) {

func GenerateRandomBytes

func GenerateRandomBytes(n int) ([]byte, error)

GenerateRandomBytes returns securely generated random bytes. It will return an error if the system's secure random number generator fails to function correctly, in which case the caller should not continue.

func GenerateRandomString

func GenerateRandomString(n int) (string, error)

GenerateRandomString returns a securely generated random string. It will return an error if the system's secure random number generator fails to function correctly, in which case the caller should not continue.

func GenerateSSHKeyPairEd25519

func GenerateSSHKeyPairEd25519(comment string, password string) (error, string, string)

return: err, pubKeyPEM, privKeyPEM

func GetBaseDomainFromDomain

func GetBaseDomainFromDomain(domain string) (string, error)

func GetCookieDefaultDomain

func GetCookieDefaultDomain() string

func GetCookieDefaultSameSitePolicy

func GetCookieDefaultSameSitePolicy() string

func GetHttpBrowserPathFromRequest

func GetHttpBrowserPathFromRequest(r *http.Request) (path string)

func GetHttpDomainAndPortFromRequest

func GetHttpDomainAndPortFromRequest(r *http.Request) (domain string, portNum string, err error)

domain can be: domain or IPv4 / IPv6

func GetHttpPathFromRequest

func GetHttpPathFromRequest(r *http.Request) (path string)

returns: `/` or `/path/extra` or `/path/extra/`

func GetHttpProtocolFromRequest

func GetHttpProtocolFromRequest(r *http.Request) (proto string)

returns: `http://` or `https://`

func GetHttpProxyBasePath

func GetHttpProxyBasePath() string

func GetHttpProxyRealClientIpHeaderKey

func GetHttpProxyRealClientIpHeaderKey() string

func GetHttpProxyRealServerHostPortHeaderKey

func GetHttpProxyRealServerHostPortHeaderKey() string

func GetHttpProxyRealServerProtoHeaderKey

func GetHttpProxyRealServerProtoHeaderKey() string

func GetHttpQueryStringFromRequest

func GetHttpQueryStringFromRequest(r *http.Request) (query string)

returns: “ or `?` or `?a` or `?a=` or `?a=b` or `?a=b&` or `?a=b&c` or `?a=b&c=` or `?a=b&c=d`

func GetHttpRealClientIpFromRequestHeaders

func GetHttpRealClientIpFromRequestHeaders(r *http.Request) (isOk bool, clientRealIp string, rawVal string, headerKey string)

func GetHttpRemoteAddrIpAndPortFromRequest

func GetHttpRemoteAddrIpAndPortFromRequest(r *http.Request) (ipAddr string, portNum string)

func GetHttpUserAgentFromRequest

func GetHttpUserAgentFromRequest(r *http.Request) (ua string)

func GzDecode

func GzDecode(str string) string

func GzDeflate

func GzDeflate(str string, level int) string

func GzEncode

func GzEncode(str string, level int) string

func GzInflate

func GzInflate(str string) string

func HTMLCodeFixSanitize

func HTMLCodeFixSanitize(htmlCode string) (string, error)

func HTMLCodeFixValidate

func HTMLCodeFixValidate(htmlCode string) (string, error)

func HandleAbortCtrlC

func HandleAbortCtrlC(delay uint32)

func HashHmac

func HashHmac(algo string, key string, str string, b64 bool) (string, error)

func Hex2Bin

func Hex2Bin(str string) string

func HttpSessionUUIDCookieIsEnabled

func HttpSessionUUIDCookieIsEnabled() bool

func HttpSessionUUIDCookieNameGet

func HttpSessionUUIDCookieNameGet() string

func HttpSessionUUIDCookieNameSet

func HttpSessionUUIDCookieNameSet(cookieName string) bool

func Implode

func Implode(glue string, pieces []string) string

func InListArr

func InListArr[E comparable](v E, arr []E) bool

func IniContentParse

func IniContentParse(iniContent string, iniKeys []string) (iniMap map[string]string, errMsg error)

func IsNetValidHostName

func IsNetValidHostName(s string) bool

func IsNetValidIpAddr

func IsNetValidIpAddr(s string) bool

func IsNetValidPortNum

func IsNetValidPortNum(p int64) bool

func IsNetValidPortStr

func IsNetValidPortStr(s string) bool

func IsPathAlikeWithSafeFixedPath

func IsPathAlikeWithSafeFixedPath(path string, fixTrailingSlashes bool) bool

func IsValidHttpHeaderKey

func IsValidHttpHeaderKey(hdrKey string) bool

func JsonArrDecode

func JsonArrDecode(data string) ([]interface{}, error)

func JsonEncode

func JsonEncode(data interface{}, prettyprint bool, htmlsafe bool) (string, error)

func JsonGetValueByKeyPath

func JsonGetValueByKeyPath(json string, path string) gjson.Result

func JsonNoErrChkEncode

func JsonNoErrChkEncode(data interface{}, prettyprint bool, htmlsafe bool) string

func JsonObjDecode

func JsonObjDecode(data string) (map[string]interface{}, error)

func JsonScalarDecodeToStr

func JsonScalarDecodeToStr(data string) (string, error)

func JsonStrDecode

func JsonStrDecode(data string) (string, error)

func LogToConsole

func LogToConsole(level string, withColorsOnConsole bool)

func LogToFile

func LogToFile(level string, pathForLogs string, theFormat string, alsoOnConsole bool, withColorsOnConsole bool)

func LogToStdErr

func LogToStdErr(level string)

func LogUseLocalTime

func LogUseLocalTime()

func LogUseUtcTime

func LogUseUtcTime()

func MarkdownToHTMLRender

func MarkdownToHTMLRender(mkdwDoc string) (string, error)

func MarkersTplEscapeSyntaxContent

func MarkersTplEscapeSyntaxContent(tpl string, isMainHtml bool) string

func MarkersTplEscapeTpl

func MarkersTplEscapeTpl(template string) string

func MarkersTplPrepareNosyntaxContent

func MarkersTplPrepareNosyntaxContent(tpl string) string

func MarkersTplPrepareNosyntaxHtml

func MarkersTplPrepareNosyntaxHtml(tpl string, isMainHtml bool) string

func MarkersTplRender

func MarkersTplRender(template string, arrobj map[string]string, isEncoded bool, revertSyntax bool, escapeRemainingSyntax bool, isMainHtml bool) string

func MarkersTplRevertNosyntaxContent

func MarkersTplRevertNosyntaxContent(tpl string) string

func Md5

func Md5(str string) string

func Md5B64

func Md5B64(str string) string

func MimeTypeByFileExtension

func MimeTypeByFileExtension(fext string) string

func MimeTypeByFilePath

func MimeTypeByFilePath(path string) string

func NewError

func NewError(err string) error

func NullableStrFromStr

func NullableStrFromStr(s string) *string

func NullableStrToStr

func NullableStrToStr(s *string) string

func PanicHandler

func PanicHandler()

call as: defer PanicHandler()

func ParseBoolStrAsBool

func ParseBoolStrAsBool(s string) bool

func ParseBoolStrAsStdBoolStr

func ParseBoolStrAsStdBoolStr(s string) string

func ParseFloatStrAsDecimalStr

func ParseFloatStrAsDecimalStr(s string, d uint8) string

func ParseStrAsFloat64

func ParseStrAsFloat64(s string) float64

func ParseStrAsFloat64StrFixedPrecision

func ParseStrAsFloat64StrFixedPrecision(s string) string

func ParseStrAsInt64

func ParseStrAsInt64(s string) int64

func ParseStrAsUInt64

func ParseStrAsUInt64(s string) uint64

func PathAddDirLastSlash

func PathAddDirLastSlash(dirPath string) string

func PathBaseExtension

func PathBaseExtension(filePath string) string

func PathBaseName

func PathBaseName(filePath string) string

func PathBaseNoExtName

func PathBaseNoExtName(filePath string) string

func PathDirName

func PathDirName(filePath string) string

func PathExists

func PathExists(thePath string) bool

func PathGetAbsoluteFromRelative

func PathGetAbsoluteFromRelative(thePath string) string

func PathGetCurrentExecutableDir

func PathGetCurrentExecutableDir() string

func PathGetCurrentExecutableName

func PathGetCurrentExecutableName() string

func PathGetCurrentExecutablePathAndName

func PathGetCurrentExecutablePathAndName() string

func PathIsAbsolute

func PathIsAbsolute(filePath string) bool

func PathIsBackwardUnsafe

func PathIsBackwardUnsafe(filePath string) bool

func PathIsDir

func PathIsDir(thePath string) bool

func PathIsEmptyOrRoot

func PathIsEmptyOrRoot(filePath string) bool

func PathIsFile

func PathIsFile(thePath string) bool

func PathIsSafeValidFileName

func PathIsSafeValidFileName(fileName string) bool

func PathIsSafeValidPath

func PathIsSafeValidPath(filePath string) bool

func PathIsSafeValidSafeFileName

func PathIsSafeValidSafeFileName(fileName string) bool

func PathIsSafeValidSafePath

func PathIsSafeValidSafePath(filePath string) bool

func Pbkdf2DerivedKey

func Pbkdf2DerivedKey(algo string, key string, salt string, klen uint16, iterations uint16, b92 bool) (string, error)

func Pbkdf2PreDerivedKey

func Pbkdf2PreDerivedKey(key string) (string, error)

func PlaceholdersTplRender

func PlaceholdersTplRender(template string, arrpobj map[string]string, isEncoded bool, revertSyntax bool) string

func Poly1305

func Poly1305(key string, str string, b64 bool) (string, error)

func PrettyPrintBytes

func PrettyPrintBytes(b int64) string

func RawUrlDecode

func RawUrlDecode(s string) string

func RawUrlEncode

func RawUrlEncode(s string) string

func RenderMainHtmlMarkersTpl

func RenderMainHtmlMarkersTpl(template string, arrobj map[string]string, arrpobj map[string]string) string

func RenderMarkersTpl

func RenderMarkersTpl(template string, arrobj map[string]string) string

func SafeChecksumHashSmart

func SafeChecksumHashSmart(plainTextData string, customSalt string) string

func SafePassHashSmart

func SafePassHashSmart(plainPass string, theSalt string, useArgon2id bool) string

func SafePathDirCreate

func SafePathDirCreate(dirPath string, allowRecursive bool, allowAbsolutePath bool) (isSuccess bool, errMsg error)

func SafePathDirDelete

func SafePathDirDelete(dirPath string, allowAbsolutePath bool) (isSuccess bool, errMsg error)

func SafePathDirRename

func SafePathDirRename(dirPath string, dirNewPath string, allowAbsolutePath bool) (isSuccess bool, errMsg error)

func SafePathDirScan

func SafePathDirScan(dirPath string, recursive bool, allowAbsolutePath bool) (isSuccess bool, errMsg error, arrDirs []string, arrFiles []string)

func SafePathEmbedDirScan

func SafePathEmbedDirScan(efs *embed.FS, dirPath string, recursive bool) (isSuccess bool, err error, arrDirs []string, arrFiles []string)

ex call (req. go ambed fs assets): SafePathEmbedDirScan(&assets, "assets/", true)

func SafePathFileCopy

func SafePathFileCopy(filePath string, fileNewPath string, allowAbsolutePath bool) (isSuccess bool, errMsg error)

func SafePathFileDelete

func SafePathFileDelete(filePath string, allowAbsolutePath bool) (isSuccess bool, errMsg error)

func SafePathFileGetSize

func SafePathFileGetSize(filePath string, allowAbsolutePath bool) (fileSize int64, errMsg error)

func SafePathFileMd5

func SafePathFileMd5(filePath string, allowAbsolutePath bool) (hashSum string, errMsg error)

func SafePathFileRead

func SafePathFileRead(filePath string, allowAbsolutePath bool) (fileContent string, errMsg error)

func SafePathFileRename

func SafePathFileRename(filePath string, fileNewPath string, allowAbsolutePath bool) (isSuccess bool, errMsg error)

func SafePathFileSha

func SafePathFileSha(mode string, filePath string, allowAbsolutePath bool) (hashSum string, errMsg error)

func SafePathFileWrite

func SafePathFileWrite(filePath string, wrMode string, allowAbsolutePath bool, fileContent string) (isSuccess bool, errMsg error)

func SafePathFixClean

func SafePathFixClean(p string) string

func SafePathFixSeparator

func SafePathFixSeparator(p string) string

this is a safer replacement for filepath.ToSlash(p), because is not OS Context Aware

func SafePathGetMTime

func SafePathGetMTime(thePath string, allowAbsolutePath bool) (mTime int64, errMsg error)

func SafePathIniFileReadAndParse

func SafePathIniFileReadAndParse(iniFilePath string, allowAbsolutePath bool, iniKeys []string) (iniMap map[string]string, errMsg error)

func SafePathYamlFileReadAndParse

func SafePathYamlFileReadAndParse(yamlFilePath string, allowAbsolutePath bool) (yamlMap map[string]interface{}, errMsg error)

func SetCookieDefaultDomain

func SetCookieDefaultDomain(domain string) bool

func SetCookieDefaultSameSitePolicy

func SetCookieDefaultSameSitePolicy(policy string) bool

func SetHttpProxyBasePath

func SetHttpProxyBasePath(pfx string) bool

func SetHttpProxyRealClientIpHeaderKey

func SetHttpProxyRealClientIpHeaderKey(hdrKey string) bool

func SetHttpProxyRealServerHostPortHeaderKey

func SetHttpProxyRealServerHostPortHeaderKey(hdrKey string) bool

func SetHttpProxyRealServerProtoHeaderKey

func SetHttpProxyRealServerProtoHeaderKey(hdrKey string) bool

func Sh3a224

func Sh3a224(str string) string

func Sh3a224B64

func Sh3a224B64(str string) string

func Sh3a256

func Sh3a256(str string) string

func Sh3a256B64

func Sh3a256B64(str string) string

func Sh3a384

func Sh3a384(str string) string

func Sh3a384B64

func Sh3a384B64(str string) string

func Sh3a512

func Sh3a512(str string) string

func Sh3a512B64

func Sh3a512B64(str string) string

func Sha1

func Sha1(str string) string

func Sha1B64

func Sha1B64(str string) string

func Sha224

func Sha224(str string) string

func Sha224B64

func Sha224B64(str string) string

func Sha256

func Sha256(str string) string

func Sha256B64

func Sha256B64(str string) string

func Sha384

func Sha384(str string) string

func Sha384B64

func Sha384B64(str string) string

func Sha512

func Sha512(str string) string

func Sha512B64

func Sha512B64(str string) string

func StrChunkSplit

func StrChunkSplit(body string, chunklen uint, end string) string

ChunkSplit chunk_split()

func StrContains

func StrContains(str string, part string) bool

func StrCreateHtmId

func StrCreateHtmId(s string) string

func StrCreateJsVarName

func StrCreateJsVarName(s string) string

func StrCreateSlug

func StrCreateSlug(s string) string

func StrDeaccent

func StrDeaccent(s string) string

func StrEndsWith

func StrEndsWith(str string, part string) bool

func StrIContains

func StrIContains(str string, part string) bool

func StrIEndsWith

func StrIEndsWith(str string, part string) bool

func StrIPos

func StrIPos(haystack, needle string) int

case insensitive, find position of first occurrence of string in a string ; multi-byte safe return -1 if can not find the substring or the position of needle in haystack

func StrIReplaceAll

func StrIReplaceAll(s string, part string, replacement string) string

case insensitive replacer

func StrIReplaceWithLimit

func StrIReplaceWithLimit(s, part, replacement string, limit int) string

case insensitive replacer

func StrIStartsWith

func StrIStartsWith(str string, part string) bool

func StrLen

func StrLen(str string) int

Strlen strlen()

func StrMBSubstr

func StrMBSubstr(s string, start int, stop int) string

func StrNl2Br

func StrNl2Br(s string) string

func StrNormalizeSpaces

func StrNormalizeSpaces(s string) string

func StrPad2LenLeft

func StrPad2LenLeft(s string, padStr string, overallLen int) string

func StrPad2LenRight

func StrPad2LenRight(s string, padStr string, overallLen int) string

func StrPos

func StrPos(haystack string, needle string) int

case sensitive, find position of first occurrence of string in a string ; multi-byte safe return -1 if can not find the substring or the position of needle in haystack

func StrRIPos

func StrRIPos(haystack, needle string) int

case insensitive, find position of last occurrence of string in a string ; multi-byte safe return -1 if can not find the substring or the position of needle in haystack

func StrRPos

func StrRPos(haystack string, needle string) int

case sensitive, find position of last occurrence of string in a string ; multi-byte safe return -1 if can not find the substring or the position of needle in haystack

func StrRegex2FindAllStringMatches

func StrRegex2FindAllStringMatches(mode string, rexp string, s string, maxRecursion uint32, maxTimeOut uint8) (rx *regexp2.Regexp, mh []string)

func StrRegexMatchString

func StrRegexMatchString(rexpr string, s string) bool

func StrRegexReplaceAll

func StrRegexReplaceAll(rexpr string, s string, repl string) string

func StrReplaceAll

func StrReplaceAll(s string, part string, replacement string) string

case sensitive replacer

func StrReplaceWithLimit

func StrReplaceWithLimit(s string, part string, replacement string, limit int) string

case sensitive replacer

func StrRev

func StrRev(s string) string

func StrStartsWith

func StrStartsWith(str string, part string) bool

func StrSubstr

func StrSubstr(s string, start int, stop int) string

func StrToLower

func StrToLower(str string) string

func StrToUpper

func StrToUpper(str string) string

func StrTrim

func StrTrim(s string, cutset string) string

func StrTrimLeft

func StrTrimLeft(s string, cutset string) string

func StrTrimLeftWhitespaces

func StrTrimLeftWhitespaces(s string) string

func StrTrimRight

func StrTrimRight(s string, cutset string) string

func StrTrimRightWhitespaces

func StrTrimRightWhitespaces(s string) string

func StrTrimWhitespaces

func StrTrimWhitespaces(s string) string

func StrUcFirst

func StrUcFirst(s string) string

func StrUcWords

func StrUcWords(s string) string

func StrUnicodeLen

func StrUnicodeLen(str string) int

MbStrlen mb_strlen()

func StrWordCount

func StrWordCount(str string) []string

StrWordCount str_word_count()

func TextCutByLimit

func TextCutByLimit(s string, length int) string

func ThreefishDecryptCBC

func ThreefishDecryptCBC(str string, key string, useArgon2id bool) string

func ThreefishDecryptTwofishBlowfishCBC

func ThreefishDecryptTwofishBlowfishCBC(str string, key string, useArgon2id bool) string

func ThreefishEncryptCBC

func ThreefishEncryptCBC(str string, key string, useArgon2id bool) string

func ThreefishEncryptTwofishBlowfishCBC

func ThreefishEncryptTwofishBlowfishCBC(str string, key string, useArgon2id bool) string

func TimeNowLocal

func TimeNowLocal() int64

func TimeNowUtc

func TimeNowUtc() int64

func TimeUnixNanoMathRandHandler

func TimeUnixNanoMathRandHandler() *mrand.Rand

func TwofishDecryptBlowfishCBC

func TwofishDecryptBlowfishCBC(str string, key string) string

func TwofishDecryptCBC

func TwofishDecryptCBC(str string, key string) string

func TwofishEncryptBlowfishCBC

func TwofishEncryptBlowfishCBC(str string, key string) string

func TwofishEncryptCBC

func TwofishEncryptCBC(str string, key string) string

func UInt64ToHex

func UInt64ToHex(num uint64) string

func UnEscapeHtml

func UnEscapeHtml(s string) string

works for HTML and XML too ...

func ValidateCookieName

func ValidateCookieName(cookieName string) bool

func XmlConvertToJson

func XmlConvertToJson(xmlData string) (string, error)

func YamlDataParse

func YamlDataParse(yamlData string) (yamlMap map[string]interface{}, errMsg error)

Types

type AuthDataStruct

type AuthDataStruct struct {
	OK           bool              // TRUE | FALSE
	ErrMsg       string            // error message (if any) or empty string
	Method       uint8             // see: HTTP_AUTH_MODE_*
	Area         string            // Auth Area
	Realm        string            // Auth Realm
	UserID       string            // User ID (if no specific ID can be the same as User Name)
	UserName     string            // User Name
	PassHash     string            // Password Hash
	PassAlgo     uint8             // Password Hash Algo ; 0 for SafePassHashSmart ; 1..255 for the rest
	EmailAddr    string            // User Email Address
	FullName     string            // Full Name
	Privileges   string            // Privileges: <priv1>,<priv2>,...
	Restrictions string            // Restrictions: <restr1>,<restr2>,...
	PrivKey      string            // Private Key
	Quota        uint64            // Quota
	MetaData     map[string]string // MetaData ... Associative Array {"key1":"Val1", "key2":"Val2", ...}

}

PRIVATE

func AuthCookieDefaultCheck

func AuthCookieDefaultCheck(authRealm string, authMode uint8, clientIP string, cookies map[string]string) (bool, AuthDataStruct)

func AuthDataGet

func AuthDataGet(ok bool, errMsg string, method uint8, area string, realm string, userID string, userName string, passHash string, passAlgo uint8, emailAddr string, fullName string, privileges string, restrictions string, privKey string, quota uint64, metaData map[string]string) AuthDataStruct

func AuthTokenDefaultCheck

func AuthTokenDefaultCheck(authRealm string, authMode uint8, clientIP string, token string, cookies map[string]string) (bool, AuthDataStruct)

func AuthUserPassDefaultCheck

func AuthUserPassDefaultCheck(authRealm string, authMode uint8, user string, pass string, cookies map[string]string, requiredUsername string, requiredPassword string) (bool, AuthDataStruct)

Directories

Path Synopsis
colorstring module
crypto
blowfish
Package blowfish implements Bruce Schneier's Blowfish encryption algorithm.
Package blowfish implements Bruce Schneier's Blowfish encryption algorithm.
dhkx
REQUIRE: go 1.16 or later
REQUIRE: go 1.16 or later
pbkdf2
Package pbkdf2 implements the key derivation function PBKDF2 as defined in RFC 2898 / PKCS #5 v2.0.
Package pbkdf2 implements the key derivation function PBKDF2 as defined in RFC 2898 / PKCS #5 v2.0.
sha3
Package sha3 implements the SHA-3 fixed-output-length hash functions and the SHAKE variable-output-length hash functions defined by FIPS-202.
Package sha3 implements the SHA-3 fixed-output-length hash functions and the SHAKE variable-output-length hash functions defined by FIPS-202.
threefish
Package threefish implements the Threefish tweakable block cipher.
Package threefish implements the Threefish tweakable block cipher.
twofish
Package twofish implements Bruce Schneier's Twofish encryption algorithm.
Package twofish implements Bruce Schneier's Twofish encryption algorithm.
data-structs
fastjson
Package fastjson provides fast JSON parsing.
Package fastjson provides fast JSON parsing.
tidwall/gjson
Package gjson provides searching for json strings.
Package gjson provides searching for json strings.
tidwall/match
Package match provides a simple pattern matcher with unicode support.
Package match provides a simple pattern matcher with unicode support.
tidwall/secret
Package secret provides simple utilities for encrypting and decrypting data.
Package secret provides simple utilities for encrypting and decrypting data.
tidwall/sjson
Package sjson provides setting json values.
Package sjson provides setting json values.
yaml
Package yaml implements YAML support for the Go language.
Package yaml implements YAML support for the Go language.
db
REQUIRE: go 1.19 or later
REQUIRE: go 1.19 or later
lib-pq
Package pq is a pure Go Postgres driver for the database/sql package.
Package pq is a pure Go Postgres driver for the database/sql package.
lib-pq/oid
Package oid contains OID constants as defined by the Postgres server.
Package oid contains OID constants as defined by the Postgres server.
lib-pq/scram
Package scram implements a SCRAM-{SHA-1,etc} client per RFC5802.
Package scram implements a SCRAM-{SHA-1,etc} client per RFC5802.
mysql
Package mysql provides a MySQL driver for Go's database/sql package.
Package mysql provides a MySQL driver for Go's database/sql package.
redcon-srv
Package redcon implements a Redis compatible server framework
Package redcon implements a Redis compatible server framework
redigo/redis
Package redis is a client for the Redis database.
Package redis is a client for the Redis database.
redigo/redisx
Package redisx contains experimental features for Redigo.
Package redisx contains experimental features for Redigo.
fastjson module
gui
logutils module
markup
markdown
Package markdown implements markdown parser and HTML renderer.
Package markdown implements markdown parser and HTML renderer.
markdown/ast
Package ast defines tree representation of a parsed markdown document.
Package ast defines tree representation of a parsed markdown document.
markdown/html
Package html implements HTML renderer of parsed markdown document.
Package html implements HTML renderer of parsed markdown document.
markdown/parser
Package parser implements parser for markdown text that generates AST (abstract syntax tree).
Package parser implements parser for markdown text that generates AST (abstract syntax tree).
svg-qrcode
Package qrcode implements a QR Code encoder.
Package qrcode implements a QR Code encoder.
svg-qrcode/bitset
Package bitset implements an append only bit array.
Package bitset implements an append only bit array.
svg-qrcode/reedsolomon
Package reedsolomon provides error correction encoding for QR Code 2005.
Package reedsolomon provides error correction encoding for QR Code 2005.
regexp2 module
textproc
difflib
Package difflib is a partial port of Python difflib module.
Package difflib is a partial port of Python difflib module.
regexp2
Package regexp2 is a regexp package that has an interface similar to Go's framework regexp engine but uses a more feature full regex engine behind the scenes.
Package regexp2 is a regexp package that has an interface similar to Go's framework regexp engine but uses a more feature full regex engine behind the scenes.
threefish module
ui
utils
log-utils
Package logutils augments the standard log package with levels ; original source taken from: github.com/hashicorp/logutils ; (c) 2018 hashicorp
Package logutils augments the standard log package with levels ; original source taken from: github.com/hashicorp/logutils ; (c) 2018 hashicorp
uuid module
web
assets/srv-assets
Req: go 1.16 or later (embed.FS is N/A on Go 1.15 or lower)
Req: go 1.16 or later (embed.FS is N/A on Go 1.15 or lower)
assets/web-assets
Req: go 1.16 or later (embed.FS is N/A on Go 1.15 or lower versions)
Req: go 1.16 or later (embed.FS is N/A on Go 1.15 or lower versions)
httputils
Req: go 1.16 or later (embed.FS is N/A on Go 1.15 or lower)
Req: go 1.16 or later (embed.FS is N/A on Go 1.15 or lower)
jsonschema
Package jsonschema provides json-schema compilation and validation.
Package jsonschema provides json-schema compilation and validation.
jsonschema/httploader
Package httploader implements loader.Loader for http/https url.
Package httploader implements loader.Loader for http/https url.
jwt
Package jwt is a Go implementation of JSON Web Tokens: http://self-issued.info/docs/draft-jones-json-web-token.html
Package jwt is a Go implementation of JSON Web Tokens: http://self-issued.info/docs/draft-jones-json-web-token.html
webdav
Package webdav provides a WebDAV server implementation.
Package webdav provides a WebDAV server implementation.
webdav/internal/xml
Package xml implements a simple XML 1.0 parser that understands XML name spaces.
Package xml implements a simple XML 1.0 parser that understands XML name spaces.
websrv
Req: go 1.16 or later (embed.FS is N/A on Go 1.15 or lower)
Req: go 1.16 or later (embed.FS is N/A on Go 1.15 or lower)
web-socket
websocket
Package websocket implements the WebSocket protocol defined in RFC 6455.
Package websocket implements the WebSocket protocol defined in RFC 6455.
websocket/examples/autobahn
Command server is a test server for the Autobahn WebSockets Test Suite.
Command server is a test server for the Autobahn WebSockets Test Suite.
ws-msgpak-srv-cli
Req: go 1.16 or later (embed.FS is N/A on Go 1.15 or lower)
Req: go 1.16 or later (embed.FS is N/A on Go 1.15 or lower)
webview module
webview2 module

Jump to

Keyboard shortcuts

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