lib

package
v1.6.7-0...-b28dd99 Latest Latest
Warning

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

Go to latest
Published: Jan 31, 2024 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DecodeJSON

func DecodeJSON(data io.Reader, out interface{}) error

DecodeJSON is a convenience function to create a JSON decoder set it up to disallow unknown fields and then decode into the given value.

func DeleteEmpty

func DeleteEmpty(s []string) []string

DeleteEmpty returns a new slice containing all non-empty strings in the original slice.

func Filter

func Filter(vs []string, f func(string) bool) []string

Filter returns a new slice containing all strings in the slice that satisfy the predicate f.

func FormatTime

func FormatTime(t time.Time) string

FormatTime returns DB compatible datetime string.

func GetAvailablePort

func GetAvailablePort() int

GetAvailablePort returns a port at random

func GetExternalIP

func GetExternalIP() (string, error)

GetExternalIP gets external ip.

func GetListenAddress

func GetListenAddress(addr string) string

GetListenAddress gets local or external listen address.

func GetLocalIP

func GetLocalIP() (ip string)

GetLocalIP gets local ip address.

func ID

func ID() string

ID returns new uuid in string format.

func Include

func Include(vs []string, t string) bool

Include returns true if the target string t is in the slice.

func Index

func Index(vs []string, t string) int

Index returns the first index of the target string t, or -1 if no match is found

func IndexUint

func IndexUint(vs []uint, t uint) int

IndexUint returns the first index of the target uint t, or -1 if not match is found.

func Map

func Map(vs []string, f func(string) string) []string

Map returns a new slice containing the results of applying the function f to each string in the original slice.

func ParseTime

func ParseTime(str string) time.Time

ParseTime returns time.Time from string.

func RandomString

func RandomString() string

RandomString returns random string.

func TimeNow

func TimeNow() *time.Time

TimeNow returns current datetime.

func UnmarshalJSON

func UnmarshalJSON(data []byte, out interface{}) error

UnmarshalJSON is a convenience function around calling DecodeJSON.

func WaitTCP

func WaitTCP(duration time.Duration, host string, port int) error

WaitTCP is used to wait for external service is available on specific host and port.

Types

This section is empty.

Jump to

Keyboard shortcuts

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