You can clean this up a bit by translating target into a namespacePath:

http://godoc.org/github.com/coreos/go-namespaces/namespace#ProcessPath

See the code in nspipe: https://github.com/coreos/go-namespaces/blob/master/nspipe/nspipe.go#L39