utils

package
v0.0.0-...-1e17dab Latest Latest
Warning

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

Go to latest
Published: Jun 25, 2023 License: MIT Imports: 15 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"
	DEFAULT_TIMESTAMP_TIME_LAYOUT = "20060102150405"
)

Variables

This section is empty.

Functions

func ExecCommand

func ExecCommand(cmd string, params []string) (int, []byte, []byte, error)

func GetCronNextTriggeredTime

func GetCronNextTriggeredTime(spec, location string, startTime time.Time) (time.Time, error)

func GetCronPeriodTriggeredTimes

func GetCronPeriodTriggeredTimes(spec string, location string, startTime, endTime time.Time) ([]time.Time, error)

func GetEnvOrIniValue

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

func GetOutBoundIP

func GetOutBoundIP() (ip string, err error)

func GetTimeLocation

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

func GetTimeNowInLoc

func GetTimeNowInLoc(location string) (time.Time, error)

func HttpResult

func HttpResult(c *gin.Context, code int, err error, data interface{})

func HttpResultWithTotalCounts

func HttpResultWithTotalCounts(c *gin.Context, code int, err error, data interface{}, counts int64)

func Response

func Response(c *gin.Context, e error, d interface{}, count int64)

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

Types

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