utils

package
v0.0.0-...-15bed1d Latest Latest
Warning

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

Go to latest
Published: Aug 19, 2022 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

View Source
const (
	GitMethodSSH   = "ssh"
	GitMethodHTTPS = "https"
	GitMethodHTTP  = "http"
)
View Source
const (
	TimeLayout = time.RFC3339
)

Variables

This section is empty.

Functions

func CombineManifests

func CombineManifests(yamls []string) string

func FloatFloor

func FloatFloor(v float64, per int) float64

FloatFloor 向下保留小数

func FloatRound

func FloatRound(v float64, per int) float64

FloatRound 四舍五入

func FormatSize

func FormatSize(size int) (res string)

FormatSize 1024

func FormatTime

func FormatTime(t time.Time) string

func NewKSuid

func NewKSuid() string

func NewRequestID

func NewRequestID() string

func NewShortUUID

func NewShortUUID() string

func NewTraceID

func NewTraceID() string

NewTraceID 链路ID

func NewXID

func NewXID() string

func Now

func Now() time.Time

func ParseGitRepo

func ParseGitRepo(source string) (owner, repo string, err error)

ParseGitRepo source: 087-group/appserver_mars_service owner: 087-group repo: appserver_mars_service

func ParseTime

func ParseTime(str string) (time.Time, error)

func RegisterValidation

func RegisterValidation(name string, fn validator.Func) error

func ShortenFileBase

func ShortenFileBase(baseDir, fullPath string) string

ShortenFileBase removes baseDir from fullPath (but keep the last element of baseDir). e.g. ShortenFileBase("a/b", "a/b/c.go") => "b/c.go"

func SplitManifests

func SplitManifests(content string) []string

func Validate

func Validate(i interface{}) error

func ValidateSnakeCase

func ValidateSnakeCase(fl validator.FieldLevel) bool

Types

type GitURL

type GitURL struct {
	Method    string // ssh or https, default is ssh
	Host      string
	Namespace string
	Repo      string
}

func ParseGitUrl

func ParseGitUrl(url string) (repo GitURL, err error)

ParseGitUrl 解析git地址 "ssh_url": "git@git.atcloudbox.com:087-group/appserver_mars_service.git", "http_url": "https://git.atcloudbox.com/087-group/appserver_mars_service.git"

type Timestamps

type Timestamps int64 // 秒

func NowTimestamps

func NowTimestamps() Timestamps

func ToTimestamps

func ToTimestamps(t time.Time) Timestamps

func (Timestamps) MarshalBinary

func (t Timestamps) MarshalBinary() (data []byte, err error)

func (Timestamps) String

func (t Timestamps) String() string

func (Timestamps) Time

func (t Timestamps) Time() time.Time

func (Timestamps) UnmarshalBinary

func (t Timestamps) UnmarshalBinary(data []byte) error

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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