lg

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Dec 8, 2022 License: MIT Imports: 8 Imported by: 2

Documentation

Index

Constants

View Source
const (
	EnvImageTag            = "IMAGE_TAG"
	EnvImageVersionMajor   = "IMAGE_VERSION_MAJOR"
	EnvImageVersionMinor   = "IMAGE_VERSION_MINOR"
	EnvImageVersionPatch   = "IMAGE_VERSION_PATCH"
	EnvImageCommitShortSha = "IMAGE_COMMIT_SHORT_SHA"
	EnvImageBuildDate      = "IMAGE_BUILD_DATE"
	EnvUnknownString       = "__unknown__"
)

Variables

View Source
var (
	MajorVersion   = 0
	MinorVersion   = 0
	PatchVersion   = 0
	ImageTag       = EnvUnknownString
	CommitShortSHA = EnvUnknownString
	ImageBuildDate = EnvUnknownString
)
View Source
var TypeOfErrorIf reflect.Type
View Source
var TypeOfTime reflect.Type
View Source
var TypeOfType reflect.Type

Functions

func Contains added in v0.0.6

func Contains[T comparable](slice []T, v T) bool

func Filter

func Filter[T any](items []T, f func(v T) (is bool)) []T

func FilterAndMap added in v0.0.8

func FilterAndMap[IN any, OUT any](items []IN, f func(v IN) (outData OUT, is bool)) []OUT

func FilterFirst

func FilterFirst[T any](items []T, f func(v T) (is bool)) (val T, exists bool)

func GetenvInt

func GetenvInt(key string, defaultValue int) int

func GetenvStr

func GetenvStr(key string, defaultValue string) string

func Ife

func Ife[T string | bool | int | any](condition bool, ifValue T, elseValue T) T

Ife 用來替代 golang 不支援 "?:" 的語法。

func IfeB deprecated

func IfeB(condition bool, ifValue bool, elseValue bool) bool

IfeB 用來替代 golang 不支援 "?:" 的語法。

Deprecated: Use lc-go/lg/Ife instead.

func IfeI deprecated

func IfeI(condition bool, ifValue int, elseValue int) int

IfeI 用來替代 golang 不支援 "?:" 的語法。

Deprecated: Use lc-go/lg/Ife instead.

func IfeS deprecated

func IfeS(condition bool, ifValue string, elseValue string) string

IfeS 用來替代 golang 不支援 "?:" 的語法。

Deprecated: Use lc-go/lg/Ife instead.

func IsError added in v0.0.8

func IsError(t reflect.Type) bool

func IsTypeInstance added in v0.0.6

func IsTypeInstance(inst any) bool

func IterateFunc

func IterateFunc[T any](items []T, f func(v T, index int) (stop bool))

func IterateFuncInversely

func IterateFuncInversely[T any](items []T, f func(v T, index int) (stop bool))

func MakeInverseIterator

func MakeInverseIterator[T any](items []T) func() (T, bool, int)

func MakeIterator

func MakeIterator[T any](items []T) func() (T, bool, int)

func Map

func Map[IN string | bool | int | any, OUT string | bool | int | any](list []IN, f func(v IN) OUT) []OUT

func Printfln

func Printfln(template string, values ...interface{})

func Reduce

func Reduce[IN any, OUT any](list []IN, initialOutputValue OUT, f func(v IN, lastResult OUT) OUT) OUT

Types

type StructTagAttr

type StructTagAttr struct {
	Orig    string
	Key     string
	Val     string
	ValOnly bool // Orig is not "xxx=yyy" pattern
}

type StructTagAttrs

type StructTagAttrs struct {
	// contains filtered or unexported fields
}

func ParseStructTag

func ParseStructTag(tagValue string) StructTagAttrs

func (*StructTagAttrs) Attrs

func (a *StructTagAttrs) Attrs() []StructTagAttr

func (*StructTagAttrs) AttrsWithKey

func (a *StructTagAttrs) AttrsWithKey() []StructTagAttr

func (*StructTagAttrs) AttrsWithValOnly

func (a *StructTagAttrs) AttrsWithValOnly() []StructTagAttr

func (*StructTagAttrs) ContainsAttrWithValOnly added in v0.0.6

func (a *StructTagAttrs) ContainsAttrWithValOnly(val string) bool

func (*StructTagAttrs) FilterAttrWithValOnly added in v0.0.8

func (a *StructTagAttrs) FilterAttrWithValOnly(f func(attr StructTagAttr) bool) []StructTagAttr

func (*StructTagAttrs) FilterValOnly added in v0.0.8

func (a *StructTagAttrs) FilterValOnly(f func(val string) bool) []string

func (*StructTagAttrs) FirstAttrWithValOnly

func (a *StructTagAttrs) FirstAttrWithValOnly() (attr StructTagAttr, exists bool)

func (*StructTagAttrs) FirstAttrsWithKey

func (a *StructTagAttrs) FirstAttrsWithKey(key string) (attr StructTagAttr, exists bool)

func (*StructTagAttrs) PreferredName added in v0.0.8

func (a *StructTagAttrs) PreferredName(key string, allowedFirstValOnly bool) (name string, exists bool)

type Version

type Version struct {
	Major          int    `json:"major"`
	Minor          int    `json:"minor"`
	Patch          int    `json:"patch"`
	BuildDate      string `json:"buildDate"`
	ImageTag       string `json:"imageTag"`
	CommitShortSHA string `json:"commitShortSHA"`
	Route          string `json:"route"`
}

Version 表示程式碼實作的版本

func LoadVerEnv

func LoadVerEnv(filenames ...string) (*Version, error)

Jump to

Keyboard shortcuts

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