forked from sneak/util
add function +func IsValidURL(url string) bool {
This commit is contained in:
5
util.go
5
util.go
@@ -8,6 +8,7 @@ import (
|
||||
"regexp"
|
||||
"time"
|
||||
|
||||
"github.com/asaskevich/govalidator"
|
||||
"github.com/hako/durafmt"
|
||||
)
|
||||
|
||||
@@ -24,6 +25,10 @@ func TimeDiffHuman(first time.Time, second time.Time) string {
|
||||
}
|
||||
}
|
||||
|
||||
func IsValidURL(url string) bool {
|
||||
return govalidator.IsURL(url) && (govalidator.IsRequestURL(url) || govalidator.IsRequestURI(url))
|
||||
}
|
||||
|
||||
// Does anyone else use uints for things that are always >=0 like counts and
|
||||
func TimeDiffAbsSeconds(first time.Time, second time.Time) uint {
|
||||
return uint(math.Abs(first.Sub(second).Truncate(time.Second).Seconds()))
|
||||
|
||||
Reference in New Issue
Block a user