sharedutils

package
v0.0.0-...-6c624c4 Latest Latest
Warning

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

Go to latest
Published: Nov 21, 2022 License: MIT Imports: 22 Imported by: 29

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ISENABLED = map[string]bool{
	"enabled": true,
	"enable":  true,
	"yes":     true,
	"y":       true,
	"true":    true,
	"1":       true,

	"disabled": false,
	"disable":  false,
	"false":    false,
	"no":       false,
	"n":        false,
	"0":        false,
}

Functions

func AllEquals

func AllEquals(v ...interface{}) bool

func ByteToString

func ByteToString(a []byte) string

ByteToString return a human readeable string of the byte

func CheckError

func CheckError(err error)

func CheckTestError

func CheckTestError(t *testing.T, err error)

func CleanForLog

func CleanForLog(s string) string

func CleanIP

func CleanIP(s string) (string, error)

func CleanMac

func CleanMac(mac string) string

func ConvertToByte

func ConvertToByte(b string) []byte

ConvertToByte convert string to byte

func ConvertToString

func ConvertToString(b []byte) string

ConvertToSting convert byte to string

func CopyHttpRequest

func CopyHttpRequest(req *http.Request) (*http.Request, error)

func CopyMap

func CopyMap(m map[interface{}]interface{}) map[interface{}]interface{}

func Dec

func Dec(ip net.IP)

Dec function use to decrement an ip

func EnvOrDefault

func EnvOrDefault(name string, defaultVal string) string

func EnvOrDefaultDuration

func EnvOrDefaultDuration(name string, defaultVal time.Duration) time.Duration

func EnvOrDefaultInt

func EnvOrDefaultInt(name string, defaultVal int) int

func IP2Int

func IP2Int(ip net.IP) uint32

func Inc

func Inc(ip net.IP)

Inc function use to increment an ip

func Int2IP

func Int2IP(nn uint32) net.IP

func IsEnabled

func IsEnabled(enabled string) bool

func IsIPv4

func IsIPv4(address net.IP) bool

IsIPv4 return true if the ip is an IPv4 address

func IsIPv6

func IsIPv6(address net.IP) bool

IsIPv6 return true if the ip is an IPv6 address

func LcFirst

func LcFirst(str string) string

func Ping

func Ping(srcIP net.IP, dstIP net.IP, ifname string, timeout int) bool

func Pinger

func Pinger(address string, timeout int) error

func PingerRaw

func PingerRaw(srcIP net.IP, dstIP net.IP, ifname string, timeout int) error

func Pingraw

func Pingraw(srcIP net.IP, dstIP net.IP, ifname string) net.PacketConn

func RandomBytes

func RandomBytes(length uint64) []byte

func ReadFromFileOrStr

func ReadFromFileOrStr(val string) string

func RemoveDuplicates

func RemoveDuplicates(elements []string) []string

RemoveDuplicates function remove duplicates elements in an array

func SprintDump

func SprintDump(args ...interface{}) string

func TupleToMap

func TupleToMap(args []interface{}) (map[interface{}]interface{}, error)

TODO: handle odd number of elements in args

func TupleToOrderedMap

func TupleToOrderedMap(args []interface{}) (*ordered_map.OrderedMap, error)

TODO: handle odd number of elements in args

func UcFirst

func UcFirst(str string) string

Types

This section is empty.

Jump to

Keyboard shortcuts

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