utils

package
v0.0.0-...-1ae172a Latest Latest
Warning

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

Go to latest
Published: Oct 8, 2023 License: Apache-2.0 Imports: 37 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var CSTZone = time.FixedZone("GMT", 8*3600)

Functions

func Contains

func Contains(strList []string, str string) bool

func ConvertTypeByJson

func ConvertTypeByJson(srcObj interface{}, destPtr interface{}) (err error)

func CreateUUID

func CreateUUID() string

func Encrypt

func Encrypt(key string) string

func ExtractTgzBytes

func ExtractTgzBytes(tgzBytes []byte) (map[string][]byte, error)

func GenerateCert

func GenerateCert(host string, validFor time.Duration, isCA bool, ecdsaCurve string) error

func GetCodeRepoName

func GetCodeRepoName(codeUrl string) string

GetCodeRepoName 获取代码库的项目名 如:https://github.com/test/testrepo.git -> testrepo git@github.com/test/testrepo.git -> testrepo

func GetImageName

func GetImageName(img string) string

GetImageName 获取镜像的名称 如:docker.io/kubespace/kubespace:latest -> kubespace/kubespace

func GetMapStringValue

func GetMapStringValue(m map[string]interface{}, k string) (s string, ok bool)

func HandleCrash

func HandleCrash(additionalHandlers ...func(interface{}))

func LookupEnvOrInt

func LookupEnvOrInt(key string, defaultVal int) int

func LookupEnvOrString

func LookupEnvOrString(key string, defaultVal string) string

func MaxInt64

func MaxInt64(x int64, ys ...int64) int64

MaxInt64 获取多个数字中的最大数字

func MergeMap

func MergeMap(mObj ...map[string]interface{}) map[string]interface{}

func MergeReplaceMap

func MergeReplaceMap(mObj ...map[string]interface{}) map[string]interface{}

func MinInt64

func MinInt64(x int64, ys ...int64) int64

MinInt64 获取多个数字中的最小数字

func NextTriggerTime

func NextTriggerTime(spec string) (t time.Time, err error)

func ParseBool

func ParseBool(str string) bool

func ParseImageName

func ParseImageName(img string, withDefault bool) (string, string, string)

ParseImageName 获取镜像的名称 如:docker.io/kubespace/kubespace:latest -> docker.io kubespace/kubespace latest

func ParseUint

func ParseUint(s string) (uint, error)

func PathExist

func PathExist(path string) bool

func ReplaceYamlPathValue

func ReplaceYamlPathValue(yamlBytes []byte, pathVal map[string]string) ([]byte, error)

ReplaceYamlPathValue 替换YAML内容path的值,且不改变原yaml其余内容 如path=a.b,即将 a:

b: xx

xx值进行替换

func RequestHost

func RequestHost(r *http.Request) (host string)

RequestHost 获取http请求的server host

func ShortUUID

func ShortUUID() string

func StringNow

func StringNow() string

func StringPtr

func StringPtr(s string) *string

func VerifyEmailFormat

func VerifyEmailFormat(email string) bool

func VerifyMobileFormat

func VerifyMobileFormat(mobileNum string) bool

VerifyMobileFormat mobile verify

Types

type Response

type Response struct {
	Code string `json:"code"`
	Msg  string `json:"msg"`
	Data any    `json:"data"`
}

func NewResponseOk

func NewResponseOk(data any) *Response

func NewResponseWithError

func NewResponseWithError(err error) *Response

func (*Response) IsSuccess

func (r *Response) IsSuccess() bool

func (*Response) Scan

func (r *Response) Scan(value any) error

func (Response) Value

func (r Response) Value() (driver.Value, error)

Value return json value, implement driver.Valuer interface

type WatchResponse

type WatchResponse struct {
	Event    string `json:"event"`
	Obj      string `json:"obj"`
	Resource any    `json:"resource"`
}

Jump to

Keyboard shortcuts

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