common

package
v0.0.0-...-f2b1faa Latest Latest
Warning

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

Go to latest
Published: Jan 12, 2024 License: MIT Imports: 42 Imported by: 0

Documentation

Overview

Package uuid provides implementation of Universally Unique Identifier (UUID). Supported versions are 1, 3, 4 and 5 (as specified in RFC 4122) and version 2 (as specified in DCE 1.1).

Index

Constants

View Source
const (
	VariantNCS = iota
	VariantRFC4122
	VariantMicrosoft
	VariantFuture
)

UUID layout variants.

View Source
const (
	DomainPerson = iota
	DomainGroup
	DomainOrg
)

UUID DCE domains.

View Source
const ClientType = "clientType"
View Source
const ClientTypeMobile = "mobile"
View Source
const GDbName string = "default"
View Source
const JPushAppKey = "9334d4c6e72e4b8ee562cd10"
View Source
const JPushSecret = "02acf03c7fa4a5da8d091673"
View Source
const JwtKey = "Dv12NpJfAr5WQ2St93r73UrAw5I2GHfVAy7MRgbqpknBxfB8LUdboIQGVI3KWIGw"
View Source
const JwtSecret string = "secret"
View Source
const KBatchPostCount = 500
View Source
const KDeltaFilesDir string = "deltas"
View Source
const KDownloadFilesDir string = "download"
View Source
const KSrvDocsDir = "static/upload/docs"
View Source
const KSrvImagesDir = "static/upload/images"
View Source
const PageCaptchaCode = "__captchaCode"
View Source
const PageCaptchaId = "__captchaId"
View Source
const PageRespContent = "data"
View Source
const PageRespCreate = "isCreate"
View Source
const PageRespEdit = "isEdit"
View Source
const PageRespInputTag = "inputTag"
View Source
const PageRespMsg = "msg"
View Source
const PageRespOk = "isOk"

page

View Source
const ProjectId string = "projectId"
View Source
const ProjectName string = "projectName"
View Source
const ReqData = "Data"

ajax

View Source
const ReqMobileSecret = "__secret"
View Source
const ReqProjectId = "ProjectId"
View Source
const ReqRelateModels = "RelateModels"
View Source
const ReqUpdateCol = "DataUpdateColumn"
View Source
const RespCode = "Code"
View Source
const RespContent = "Content"
View Source
const RespMsg = "Msg"
View Source
const RoleIdStr string = "roleIdStr"
View Source
const RongCloudToken string = "rongCloudToken"
View Source
const SessionUpdateTag string = "_sut_"
View Source
const SuperAdminId = "admin0000"
View Source
const TreeRootId = "__root__"
View Source
const UserId string = "userId"

Variables

View Source
var (
	NamespaceDNS, _  = FromString("6ba7b810-9dad-11d1-80b4-00c04fd430c8")
	NamespaceURL, _  = FromString("6ba7b811-9dad-11d1-80b4-00c04fd430c8")
	NamespaceOID, _  = FromString("6ba7b812-9dad-11d1-80b4-00c04fd430c8")
	NamespaceX500, _ = FromString("6ba7b814-9dad-11d1-80b4-00c04fd430c8")
)

Predefined namespace UUIDs.

View Source
var Nil = UUID{}

The nil UUID is special form of UUID that is specified to have all 128 bits set to zero.

Functions

func Compress

func Compress(data []byte) []byte

func CompressFile

func CompressFile(srcFile, destFile string) error

func ConvertFileSize

func ConvertFileSize(fsize int64) string

func ConvertToTree

func ConvertToTree(params *[]orm.Params) []orm.Params

func CreateModel

func CreateModel(name string) interface{}

func CreateModels

func CreateModels(name string) interface{}

返回的是 结构体的数组指针 即 []*struct

func DeCompress

func DeCompress(data []byte) []byte

func DeCompressFile

func DeCompressFile(srcFile, destFile string) error

func DeCompressZip

func DeCompressZip(zipFile, dest string) error

func DeSqlInject

func DeSqlInject(paramVal string) string

func DeSqlInject2

func DeSqlInject2(paramVal string) string

func DesDecrypt

func DesDecrypt(data, key string) (string, error)

func DesEncrypt

func DesEncrypt(data, key string) (string, error)

func Equal

func Equal(u1 UUID, u2 UUID) bool

Equal returns true if u1 and u2 equals, otherwise returns false.

func FileExist

func FileExist(filename string) bool

func FindStrArray

func FindStrArray(arr []string, f string) int

func GBK2UTF8

func GBK2UTF8(s []byte) ([]byte, error)

func GetCurrPath

func GetCurrPath() string

获取当前文件执行的路径

func GetDeltaFileTmpDir

func GetDeltaFileTmpDir() string

func GetDocsPathConf

func GetDocsPathConf() string

func GetDownloadFileTmpDir

func GetDownloadFileTmpDir() string

func GetImagesPathConf

func GetImagesPathConf() string

func GetModelNames

func GetModelNames() []string

func GetParentDirectory

func GetParentDirectory(dirctory string) string

func GetRealPath

func GetRealPath(basePath, urlPath, name string) string

func GetRedisConf

func GetRedisConf() (string, string, string, int)

func GetRegModel

func GetRegModel(name string) interface{}

func GetRegModelType

func GetRegModelType(modelName string) reflect.Type

func GetRegModels

func GetRegModels() []interface{}

func GetUserImgUrl

func GetUserImgUrl(userId string, pictrueId string) string

func IsModelHasField

func IsModelHasField(modelName string, fieldName string) bool

func IsNil

func IsNil(d interface{}) bool

func IsNotBlank

func IsNotBlank(str string) bool

func Md5Hash

func Md5Hash(content string) string

func Md5HashEncrypt

func Md5HashEncrypt(password string, salt string) string

func NewGuid

func NewGuid() string

func ObjContains

func ObjContains(obj interface{}, target interface{}) (bool, error)

func PKCS5Padding

func PKCS5Padding(ciphertext []byte, blockSize int) []byte

func PKCS5UnPadding

func PKCS5UnPadding(origData []byte) []byte

func ReadBytes

func ReadBytes(reader io.Reader) []byte

func ReadImage

func ReadImage(filePath string) (image.Image, error)

func ReflectSetEntity

func ReflectSetEntity(entType reflect.Type, dbentv reflect.Value, entMap map[string]interface{}, isUpdate bool)

func ReflectSetValue

func ReflectSetValue(entType reflect.Type, entObj reflect.Value, filedName string, v interface{})

func RegisterModels

func RegisterModels(models ...interface{})

func Round2

func Round2(f float64, n int) float64

func SaveImage

func SaveImage(c *gin.Context, file *multipart.FileHeader, ownerId string) string

func SendEmail

func SendEmail(receivers []string, subject string, body string) bool

func SetCRUDStruct

func SetCRUDStruct(h gin.H, err error, op string, entity interface{}, retentity bool)

func SetPageToken

func SetPageToken(c *gin.Context, h gin.H)

func Sha256HashEncrypt

func Sha256HashEncrypt(password string, salt string) string

func StrArrayContains

func StrArrayContains(s []string, e string) (bool, int)

func StrArrayDelete

func StrArrayDelete(ss []string, index int) []string

func Substr

func Substr(s string, pos, length int) string

func ToFsPath

func ToFsPath(urlPath string) string

func ToUrlPath

func ToUrlPath(urlPath string) string

func UTF82GBK

func UTF82GBK(s []byte) ([]byte, error)

func WriteImage

func WriteImage(img image.Image, filePath string) error

func ZipFile

func ZipFile(srcFilePath, destFilePath string) error

Types

type HttpResult

type HttpResult struct {
	Code int    `json:"code"`
	Msg  string `json:"msg"`
}

type UUID

type UUID [16]byte

UUID representation compliant with specification described in RFC 4122.

func And

func And(u1 UUID, u2 UUID) UUID

And returns result of binary AND of two UUIDs.

func FromBytes

func FromBytes(input []byte) (u UUID, err error)

FromBytes returns UUID converted from raw byte slice input. It will return error if the slice isn't 16 bytes long.

func FromString

func FromString(input string) (u UUID, err error)

FromString returns UUID parsed from string input. Input is expected in a form accepted by UnmarshalText.

func NewV1

func NewV1() UUID

NewV1 returns UUID based on current timestamp and MAC address.

func NewV2

func NewV2(domain byte) UUID

NewV2 returns DCE Security UUID based on POSIX UID/GID.

func NewV3

func NewV3(ns UUID, name string) UUID

NewV3 returns UUID based on MD5 hash of namespace UUID and name.

func NewV4

func NewV4() UUID

NewV4 returns random generated UUID.

func NewV5

func NewV5(ns UUID, name string) UUID

NewV5 returns UUID based on SHA-1 hash of namespace UUID and name.

func Or

func Or(u1 UUID, u2 UUID) UUID

Or returns result of binary OR of two UUIDs.

func (UUID) Bytes

func (u UUID) Bytes() []byte

Bytes returns bytes slice representation of UUID.

func (UUID) MarshalBinary

func (u UUID) MarshalBinary() (data []byte, err error)

MarshalBinary implements the encoding.BinaryMarshaler interface.

func (UUID) MarshalText

func (u UUID) MarshalText() (text []byte, err error)

MarshalText implements the encoding.TextMarshaler interface. The encoding is the same as returned by String.

func (*UUID) Scan

func (u *UUID) Scan(src interface{}) error

Scan implements the sql.Scanner interface. A 16-byte slice is handled by UnmarshalBinary, while a longer byte slice or a string is handled by UnmarshalText.

func (*UUID) SetVariant

func (u *UUID) SetVariant()

SetVariant sets variant bits as described in RFC 4122.

func (*UUID) SetVersion

func (u *UUID) SetVersion(v byte)

SetVersion sets version bits.

func (UUID) String

func (u UUID) String() string

Returns canonical string representation of UUID: xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx.

func (*UUID) UnmarshalBinary

func (u *UUID) UnmarshalBinary(data []byte) (err error)

UnmarshalBinary implements the encoding.BinaryUnmarshaler interface. It will return error if the slice isn't 16 bytes long.

func (*UUID) UnmarshalText

func (u *UUID) UnmarshalText(text []byte) (err error)

UnmarshalText implements the encoding.TextUnmarshaler interface. Following formats are supported: "6ba7b810-9dad-11d1-80b4-00c04fd430c8", "{6ba7b810-9dad-11d1-80b4-00c04fd430c8}", "urn:uuid:6ba7b810-9dad-11d1-80b4-00c04fd430c8"

func (UUID) Variant

func (u UUID) Variant() uint

Variant returns UUID layout variant.

func (UUID) Version

func (u UUID) Version() uint

Version returns algorithm version used to generate UUID.

Directories

Path Synopsis
Package smtp implements the Simple Mail Transfer Protocol as defined in RFC 5321.
Package smtp implements the Simple Mail Transfer Protocol as defined in RFC 5321.

Jump to

Keyboard shortcuts

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