netx

package
v1.86.4 Latest Latest
Warning

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

Go to latest
Published: Aug 7, 2025 License: BSD-3-Clause Imports: 3 Imported by: 0

Documentation

Overview

Package netx contains types to describe and abstract over how dialing and listening are performed.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type DialFunc

type DialFunc func(ctx context.Context, network, address string) (net.Conn, error)

DialFunc is a function that dials a network address.

It's the type implemented by net.Dialer.DialContext or required by net/http.Transport.DialContext, etc.

type Network

type Network interface {
	NewLocalTCPListener() net.Listener
	Listen(network, address string) (net.Listener, error)
	Dial(ctx context.Context, network, address string) (net.Conn, error)
}

Network describes a network that can listen and dial. The two common implementations are RealNetwork, using the net package to use the real network, or [memnet.Network], using an in-memory network (typically for testing)

func RealNetwork

func RealNetwork() Network

RealNetwork returns a Network implementation that uses the real net package.

Jump to

Keyboard shortcuts

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