util

package
v2.0.2 Latest Latest
Warning

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

Go to latest
Published: Nov 18, 2026 License: MIT Imports: 11 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Diff

func Diff(a, b []string) ([]string, []string)

Diff computes the diff of two string slices a and b, returns a-b and b-a

func IsClosedErr

func IsClosedErr(err error) bool

IsClosedErr is a helper function to check for "already closed" errors, which are usually harmless but still show up in logs, code adapted from https://stackoverflow.com/questions/44974984/how-to-check-a-net-conn-is-closed

func Member

func Member(list []string, a string) bool

check is list contains element a

func Remove

func Remove(ss []string, e string) []string

Remove removes a given element from string slice

func Unique

func Unique(s []string) []string

Unique returns unique elements in a string slice

Types

type Endpoint

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

Endpoint is a pair of an IP prefix and a port range.

func ParseEndpoint

func ParseEndpoint(ep string) (*Endpoint, error)

ParseEndpoint parses an endpoint from the canonical format: "<IP>[optional slash and prefix length]:<minPort-maxPort)."

func (*Endpoint) Contains

func (ep *Endpoint) Contains(ip net.IP) bool

Contains reports whether the endpoint network includes ip.

func (*Endpoint) Match

func (ep *Endpoint) Match(ip net.IP, port int) bool

Match reports whether the endpoint network includes ip and port. If port is zero then port-matching is disabled.

func (*Endpoint) String

func (ep *Endpoint) String() string

type FileConnAddr

type FileConnAddr struct {
	File *os.File
}

FileConnAddr is the net.Addr of a conn backed by an os.File (the stdin/stdout pair of a STDIN listener).

func (*FileConnAddr) Network

func (s *FileConnAddr) Network() string

func (*FileConnAddr) String

func (s *FileConnAddr) String() string

type StdioListener

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

StdioListener is the one-shot listener of a STDIN listener: it accepts a single conn, the process stdin/stdout pair. EOF on stdin ends the flow. The process owns stdio: closing the listener or the conn leaves it alone.

func NewStdioListener

func NewStdioListener() *StdioListener

NewStdioListener creates the listener of the process stdin/stdout pair.

func (*StdioListener) Accept

func (l *StdioListener) Accept() (net.Conn, error)

func (*StdioListener) Addr

func (l *StdioListener) Addr() net.Addr

func (*StdioListener) Close

func (l *StdioListener) Close() error

Jump to

Keyboard shortcuts

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