util

package
v0.0.0-...-95432f6 Latest Latest
Warning

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

Go to latest
Published: Jan 9, 2023 License: MIT Imports: 13 Imported by: 0

Documentation

Index

Constants

View Source
const (
	Month_TIME_LAYOUT      = "2006-01"
	DEFAULT_TIME_LAYOUT    = "2006-01-02"
	DEFAULT_DB_TIME_LAYOUT = "2006-01-02 15:04:05"
)

Variables

This section is empty.

Functions

func Came2KebabCase

func Came2KebabCase(name string) string

func Camel2Case

func Camel2Case(name string) string

func Case2Camel

func Case2Camel(name string) string

func Contains

func Contains[T comparable](sources []T, target T) bool

判断元素target是否在sources中存在,存在返回true, 反之返回false

func ContainsArray

func ContainsArray[T comparable](sources []T, targets ...T) bool

判断数组元素targets是否都在sources中存在,全部存在返回true, 反之返回false

func Difference

func Difference[T comparable](a1, a2 []T) []T

取两个切片数组的diff 返回a1无法在a2中找到的元素数组。

func GetAgeString

func GetAgeString(t time.Time) string

func GetEnvOrIniValue

func GetEnvOrIniValue(iniFile *ini.File, section string, key string) string

func GetFileNameByTempFile

func GetFileNameByTempFile(username, tempFileName string) string

func GetFileTypeByFileName

func GetFileTypeByFileName(filename string) string

func GetFormFile

func GetFormFile(c *models.ReqContext, key string) ([]byte, error)

func GetMonthsFromTimeRange

func GetMonthsFromTimeRange(timeFrom, timeTo time.Time) ([]string, error)

func GetTempFileName

func GetTempFileName(username, filename string) string

func GetTimeLocation

func GetTimeLocation(location string) (*time.Location, error)

func Intersection

func Intersection[T comparable](a1, a2 []T) []T

取两个切片数组的交集

func Lcfirst

func Lcfirst(str string) string

func SetDefaultBool

func SetDefaultBool(targetstr string, defaultVal bool) bool

func SetDefaultDuration

func SetDefaultDuration(targetstr string, defaultVal ...time.Duration) time.Duration

func SetDefaultFloat64

func SetDefaultFloat64(targetstr string, defaultVal ...float64) float64

func SetDefaultInt

func SetDefaultInt(targetstr string, defaultVal int) int

func SetDefaultInt64

func SetDefaultInt64(targetstr string, defaultVal int64) int64

func SetDefaultString

func SetDefaultString(targetstr string, defaultVal string) string

func SplitString

func SplitString(str string) []string

func StrToBoolean

func StrToBoolean(value string) bool

func StringsFallback2

func StringsFallback2(val1 string, val2 string) string

func StringsFallback3

func StringsFallback3(val1 string, val2 string, val3 string) string

func SubMonth

func SubMonth(later, earlier time.Time) (month int)

func Ucfirst

func Ucfirst(str string) string

func Union

func Union[T comparable](a1, a2 []T) []T

取两个切片数组集合的并集

func ValidateEmail

func ValidateEmail(email string) bool

Types

type Buffer

type Buffer struct {
	*bytes.Buffer
}

func NewBuffer

func NewBuffer() *Buffer

func (*Buffer) Append

func (b *Buffer) Append(i interface{}) *Buffer

type NetworkAddress

type NetworkAddress struct {
	Host string
	Port string
}

func SplitHostPort

func SplitHostPort(input string) (NetworkAddress, error)

SplitHostPort splits ip address/hostname string by host and port

func SplitHostPortDefault

func SplitHostPortDefault(input, defaultHost, defaultPort string) (NetworkAddress, error)

SplitHostPortDefault splits ip address/hostname string by host and port. Defaults used if no match found

Jump to

Keyboard shortcuts

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