utils

package
v0.12.0 Latest Latest
Warning

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

Go to latest
Published: Oct 15, 2018 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AddrIsLocal added in v0.11.0

func AddrIsLocal(addr net.Addr) bool

AddrIsLocal returns whether the address is from a trusted local connection (loopback or unix).

func AddrIsUnix added in v0.11.0

func AddrIsUnix(addr net.Addr) bool

AddrIsUnix returns whether the address is a unix domain socket.

func AddrLookupHostname

func AddrLookupHostname(addr net.Addr) string

AddrLookupHostname returns the hostname (if possible) or address for the given `net.Addr`.

func AddrToIP added in v0.11.0

func AddrToIP(addr net.Addr) net.IP

AddrToIP returns the IP address for a net.Addr, or nil if it's a unix domain socket.

func ArgsToStrings

func ArgsToStrings(maxLength int, arguments []string, delim string) []string

ArgsToStrings takes the arguments and splits them into a series of strings, each argument separated by delim and each string bounded by maxLength.

func BitsetEmpty added in v0.12.0

func BitsetEmpty(set []uint64) (empty bool)

BitsetEmpty returns whether the bitset is empty. This has false positives under concurrent modification (i.e., it can return true even though w.r.t. the sequence of atomic modifications, there was no point at which the bitset was completely empty), but that's not how we're using this method.

func BitsetGet added in v0.12.0

func BitsetGet(set []uint64, position uint) bool

BitsetGet returns whether a given bit of the bitset is set.

func BitsetInitialize added in v0.12.0

func BitsetInitialize(set []uint64)

BitsetInitialize initializes a bitset.

func BitsetSet added in v0.12.0

func BitsetSet(set []uint64, position uint, on bool) (changed bool)

BitsetSet sets a given bit of the bitset to 0 or 1, returning whether it changed.

func BitsetUnion added in v0.12.0

func BitsetUnion(set []uint64, other []uint64)

BitsetUnion modifies `set` to be the union of `set` and `other`. This has race conditions in that we don't necessarily get a single consistent view of `other` across word boundaries.

func CopyFile added in v0.12.0

func CopyFile(src string, dst string) (err error)

implementation of `cp` (go should really provide this...)

func ExtractParam added in v0.11.0

func ExtractParam(line string) (string, string)

ExtractParam extracts a parameter from the given string, returning the param and the rest of the string.

func GetClientOnlyTags added in v0.11.0

func GetClientOnlyTags(tags map[string]ircmsg.TagValue) *map[string]ircmsg.TagValue

GetClientOnlyTags takes a tag map and returns a map containing just the client-only tags from it.

func IPString

func IPString(addr net.Addr) string

IPString returns a simple IP string from the given net.Addr.

func IsHostname

func IsHostname(name string) bool

IsHostname returns whether we consider `name` a valid hostname.

func LookupHostname

func LookupHostname(addr string) string

LookupHostname returns the hostname for `addr` if it has one. Otherwise, just returns `addr`.

Types

This section is empty.

Jump to

Keyboard shortcuts

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