h

package module
v0.0.0-...-b41d4c3 Latest Latest
Warning

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

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

README

go-helpers

A group of common helper functions to use in different projects

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Base64Decode

func Base64Decode(s string) (string, error)

func CleanString

func CleanString(s string) string

func FileExists

func FileExists(path string) bool

func FileToArray

func FileToArray(path string) ([]string, error)

func GetGzUrl

func GetGzUrl(u string) (b []byte, err error)

func GetResponse

func GetResponse(u string) (r *http.Response, err error)

func GetUrl

func GetUrl(u string) (b []byte, err error)

func InArray

func InArray(k string, arr []string) bool

func IsPrivateIPv6

func IsPrivateIPv6(ipv6 string) bool

func IsPrivateIp

func IsPrivateIp(ip string) (bool, error)

func IsPrivateIpv4

func IsPrivateIpv4(ipv4 string) (bool, error)

func IsPublicIpv6

func IsPublicIpv6(ipv6 string) bool

func IsStopWord

func IsStopWord(s string) bool

func IsValidIp

func IsValidIp(address string) bool

func JsonUrl

func JsonUrl(u string, t interface{}) (err error)

func LiftRLimits

func LiftRLimits() (rLimit syscall.Rlimit, err error)

func LogOnError

func LogOnError(e error)

func MapSearch

func MapSearch(i interface{}, keys ...string) (m map[string]interface{}, b bool)

func Md5

func Md5(text string) string

func NetworkInterfaces

func NetworkInterfaces() (interfaces []net.Interface, err error)

func OneFloat64Of

func OneFloat64Of(s ...float64) float64

func OneOf

func OneOf(s ...string) string

func OneSliceOf

func OneSliceOf(s ...[]string) []string

func OneTimeOf

func OneTimeOf(s ...time.Time) time.Time

func PanicOnError

func PanicOnError(e error)

func ParseUrl

func ParseUrl(s string) *url.URL

func RandomNumber

func RandomNumber(min int, max int) int

func RandomString

func RandomString(n int) string

func ReCaptcha

func ReCaptcha(secret, response string) (bool, error)

func ReadFile

func ReadFile(p string) (string, error)

func RegexReplaceAllStringFunc

func RegexReplaceAllStringFunc(re *regexp.Regexp, str string, repl func([]string) string) string

func Retry

func Retry(retryFunc func() error, maxRetries int) (err error)

func RunEvery

func RunEvery(ttl time.Duration, f func())

func SendMail

func SendMail(addr, from, subject, body string, to []string) error

ex: SendMail("127.0.0.1:25", (&mail.Address{"from name", "from@example.com"}).String(), "Email Subject", "message body", []string{(&mail.Address{"to name", "to@example.com"}).String()})

func Slug

func Slug(s string) string

func SubString

func SubString(s string, l int) string

func Tags

func Tags(s string, minChar, maxNum int) (tags []string)

func TrimLine

func TrimLine(s string) string

func TrimWhitespace

func TrimWhitespace(s string) string

func Utf8Encode

func Utf8Encode(s string) string

func WriteFile

func WriteFile(path, content string) (err error)

Types

type Flock

type Flock struct {
	*os.File
}

func NewFlock

func NewFlock(path string) (*Flock, error)

func (*Flock) UnLock

func (f *Flock) UnLock() error

type NoRetryError

type NoRetryError struct {
	// contains filtered or unexported fields
}

func NewNoRetryError

func NewNoRetryError(err error) NoRetryError

func (NoRetryError) Error

func (e NoRetryError) Error() string

type WaitGroupRunner

type WaitGroupRunner struct {
	*sync.WaitGroup
	// contains filtered or unexported fields
}

func NewWgExec

func NewWgExec(maxConcurrency int64) *WaitGroupRunner

func (*WaitGroupRunner) Run

func (w *WaitGroupRunner) Run(f func(params ...interface{}), args ...interface{})

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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