utils

package
v0.5.0 Latest Latest
Warning

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

Go to latest
Published: May 31, 2020 License: BSD-3-Clause Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ClearSignals added in v0.5.0

func ClearSignals(c chan<- os.Signal)

ClearSignals clears any signals that have been registered on the provided channel and closes the channel.

func CopyBytes added in v0.5.0

func CopyBytes(b []byte) []byte

CopyBytes returns a copy of the provided byte slice. If nil is provided, nil will be returned.

func HandleSignals added in v0.5.0

func HandleSignals(f func(os.Signal), sigs ...os.Signal) chan<- os.Signal

HandleSignals calls f if the go runtime receives the any of the provided signals with the received signal.

If f is nil or there are no provided signals, then nil will be returned. Otherwise, a signal channel will be returned that can be used to clear the signals registed by this function by valling ClearSignals.

func IsSortedAndUnique

func IsSortedAndUnique(data sort.Interface) bool

IsSortedAndUnique returns true if the elements in the data are unique and sorted.

func IsSortedAndUniqueUint32

func IsSortedAndUniqueUint32(u32 []uint32) bool

IsSortedAndUniqueUint32 returns true if the array of uint32s are sorted and unique

func SortUint32

func SortUint32(u32 []uint32)

SortUint32 sorts an uint32 array

Types

type IPDesc

type IPDesc struct {
	IP   net.IP
	Port uint16
}

IPDesc ...

func ToIPDesc

func ToIPDesc(str string) (IPDesc, error)

ToIPDesc ...

func (IPDesc) Equal

func (ipDesc IPDesc) Equal(otherIPDesc IPDesc) bool

Equal ...

func (IPDesc) IsPrivate

func (ipDesc IPDesc) IsPrivate() bool

IsPrivate attempts to decide if the ip address in this descriptor is a local ip address. This function was taken from: https://stackoverflow.com/a/50825191/3478466

func (IPDesc) IsZero

func (ipDesc IPDesc) IsZero() bool

IsZero returns if the IP or port is zeroed out

func (IPDesc) PortString

func (ipDesc IPDesc) PortString() string

PortString ...

func (IPDesc) String

func (ipDesc IPDesc) String() string

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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