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.
Click to show internal directories.
Click to hide internal directories.