Help us shape the future of Go! Take the 2026 Go Developer Survey

scriptnet

package
v1.20.4 Latest Latest
Warning

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

Go to latest
Published: Oct 23, 2026 License: Apache-2.0 Imports: 16 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type NetNSManager

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

func NewNSManager

func NewNSManager(t testing.TB) (*NetNSManager, error)

NewNSManager creates a new uninitialized NetNSManager.

func (*NetNSManager) Commands

func (nsm *NetNSManager) Commands() map[string]script.Cmd

Commands provides a set of script commands for managing network namespaces, links, addresses, and routes. These are designed to be used in test scripts to create ephemeral network namespaces to perform tests.

func (*NetNSManager) LockThreadAndInitialize

func (nsm *NetNSManager) LockThreadAndInitialize(t testing.TB, isolated bool) error

LockThreadAndInitialize locks the current thread to the OS thread and initializes the NetNSManager. It also registers a cleanup function, unlocking the thread on test completion, switching to the original network namespace, and closing all test namespaces.

The `isolated` parameter determines whether to start in the current network namespace or to completely isolate the test environment by starting in a new network namespace. Non-isolated mode allows a script to setup a link to the host network namespace but risks a mistake in a script corrupting the host network namespace.

Jump to

Keyboard shortcuts

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