base

package
v1.0.12 Latest Latest
Warning

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

Go to latest
Published: Mar 7, 2022 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Convert2Yaml added in v1.0.8

func Convert2Yaml(c interface{}) (string, error)

Convert2Yaml 将对象转为yaml文本

func CreateTime

func CreateTime(millis int64) time.Time

CreateTime returns the local Time corresponding to the given Unix time, sec seconds and nsec nanoseconds since January 1, 1970 UTC. It is valid to pass nsec outside the range [0, 999999999]. Not all sec values have a corresponding time value. One such value is 1<<63-1 (the largest int64 value).

func GetDateString

func GetDateString(t time.Time) string

GetDateString gets short date format like '2018-11-11'.

func GetDay

func GetDay(t time.Time) int

GetDay gets the day of the month.

func GetHour

func GetHour(t time.Time) int

GetHour gets hour number.

func GetHumanReadableDuration

func GetHumanReadableDuration(start time.Time, end time.Time) string

GetHumanReadableDuration gets a duration between times and returns format like '01:12:31' (?hour:?minute:?second).

func GetLongDateString

func GetLongDateString(t time.Time) string

GetLongDateString gets date format like '2018-11-11 12:12:12'.

func GetLongHumanReadableDuration

func GetLongHumanReadableDuration(start time.Time, end time.Time) string

GetLongHumanReadableDuration gets a duration between times and returns format like '1d 3h 12m 11s' (?day ?hour ?minute ?second).

func GetLongLongDateString

func GetLongLongDateString(t time.Time) string

GetLongLongDateString gets short date format like '2018-11-11 12:12:12,233'.

func GetMillionSecond

func GetMillionSecond(t time.Time) int

GetMillionSecond gets millionSecond number.

func GetMinute

func GetMinute(t time.Time) int

GetMinute gets minute number.

func GetMonth

func GetMonth(t time.Time) int

GetMonth gets month number.

func GetMyAddress

func GetMyAddress(preferredNetworks ...string) string

GetMyAddress get self ip address by preferred interface

func GetNanosecond

func GetNanosecond(t time.Time) int64

GetNanosecond gets current timestamp in Nanosecond.

func GetSecond

func GetSecond(t time.Time) int

GetSecond gets second number.

func GetShortDateString

func GetShortDateString(t time.Time) string

GetShortDateString gets time format like '12:12:12'.

func GetTimestamp

func GetTimestamp(t time.Time) int64

GetTimestamp gets current timestamp in milliseconds.

func GetYear

func GetYear(t time.Time) int

GetYear gets year number.

func LimitRange

func LimitRange(value interface{}, defaultValue interface{}, rangeValues ...interface{}) interface{}

LimitRange limits a variable's value in a value range. returns defaultValue if the range not provided or the value is not in the range,

func List2Array

func List2Array(ls *list.List) []interface{}

List2Array converts list to array.

func ParseHostPortFromConnStr

func ParseHostPortFromConnStr(connStr string) (string, int)

ParseHostPortFromConnStr parses host and port from connection string.

func ParseYamlFromString added in v1.0.8

func ParseYamlFromString(input string, target interface{}) error

ParseYamlFromString 从字符串解析yaml为对象

func TOperation

func TOperation(condition bool, trueOperation func() interface{}, falseOperation func() interface{}) interface{}

TOperation simulates ternary operation.

func TValue

func TValue(condition bool, trueValue interface{}, falseValue interface{}) interface{}

TValue ternary operation

func Try

func Try(f func(), catcher func(e interface{}))

Try simulates try catch

func WalkList

func WalkList(ls *list.List, walker func(item interface{}) bool)

WalkList walk a list. walker return value as break signal, if it is true, break walking

Types

type IP

type IP struct {
	Address string
	Name    string
}

Jump to

Keyboard shortcuts

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