utils

package
v0.0.0-...-32d98f7 Latest Latest
Warning

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

Go to latest
Published: Mar 22, 2024 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var GlobalLoc *time.Location

GlobalLoc is global timezone for converting time format

Functions

func ConvTimeFmt

func ConvTimeFmt(timeStr, inFmt, outFmt string) (string, error)

ConvTimeFmt converts time from input format to ouput format

func ConvTimeFmtInLocation

func ConvTimeFmtInLocation(timeStr, inFmt, outFmt string, loc *time.Location) (string, error)

ConvTimeFmtInLocation converts time from input format with timezone to ouput format in UTC

func ForceQueryPSPlusOne

func ForceQueryPSPlusOne(ps string) bool

If length of all the items in public suffix less than 3, force query publicsuffix + 1 first no matter it's ICANN-managed domain or not E.g. "co.uk", "jpn.com", "net.ua" -> true E.g. "github.io", "zhitomir.ua" -> false

func GetDescentLevel

func GetDescentLevel(ps string) string

GetDescentLevel get n-1 level of ps E.g., "abc.co.com" -> "co.com"

func GetGlobalLoc

func GetGlobalLoc() (*time.Location, error)

GetGlobalLoc get global timezone if set, else load again

func GetHost

func GetHost(domain string) (string, error)

GetHost fetch host from "<host>:<port>" string, and return input string if it does not contain port

func GetPublicSuffixs

func GetPublicSuffixs(domain string) ([]string, error)

GetPublicSuffixs returns public suffixs of input domain

func GetTLD

func GetTLD(ps string) string

return string after first ".", and return input string if it does not contains "." E.g,

GetTLD("aaa.aaa") = "aaa"
GetTLD("pooch.co.uk") = "co.uk"
GetTLD("com") = "com"

func GuessTimeFmt

func GuessTimeFmt(timeStr string, loc *time.Location) (time.Time, error)

GuessTimeFmt guesses input time string and converts to time object

func GuessTimeFmtAndConvert

func GuessTimeFmtAndConvert(timeStr, outFmt string) (string, error)

GuessTimeFmtAndConvert guesses input time string and converts to output format string

func IsIP

func IsIP(host string) bool

IsIP return true if input host string is a valid IP

func IsTimeout

func IsTimeout(err error) bool

IsTimeout return whether an error is classified as **timeout** error

func SetGlobalLoc

func SetGlobalLoc() (err error)

SetGlobalLoc set global timezone

func StrInArray

func StrInArray(val string, arr []string) bool

StrInArray returns whether item is in array

func UTCNow

func UTCNow() time.Time

UTCNow returns now in utc timezone

Types

This section is empty.

Jump to

Keyboard shortcuts

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