netns

package
v1.2.1 Latest Latest
Warning

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

Go to latest
Published: Apr 8, 2023 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Overview

Package netns supports running unit tests in separated transient network namespaces.

Usage

Just call EnterTransientNetns and defer its return value.

  import "github.com/notwork/netns"

  It("tests something inside a temporary network namespace", func() {
	defer netns.EnterTransientNetns()() // !!! double ()
	// ...
  })

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func EnterTransientNetns

func EnterTransientNetns() func()

EnterTransientNetns creates and enters a new (and isolated) network namespace, returning a function that needs to be defer'ed in order to correctly switch the calling go routine and its locked OS-level thread back when the caller itself returns.

In case the caller cannot be switched back correctly, the defer'ed clean up will panic with an error description.

Types

This section is empty.

Jump to

Keyboard shortcuts

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