Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/xgfone/go-linux-namespace
The operation about linux namespace.
https://github.com/xgfone/go-linux-namespace
linux linux-namespace namespace
Last synced: about 1 month ago
JSON representation
The operation about linux namespace.
- Host: GitHub
- URL: https://github.com/xgfone/go-linux-namespace
- Owner: xgfone
- License: apache-2.0
- Created: 2021-06-12T13:47:02.000Z (over 3 years ago)
- Default Branch: master
- Last Pushed: 2022-01-07T15:23:39.000Z (almost 3 years ago)
- Last Synced: 2024-10-30T20:49:07.755Z (2 months ago)
- Topics: linux, linux-namespace, namespace
- Language: Go
- Homepage:
- Size: 12.7 KB
- Stars: 0
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Linux Namespace [![Build Status](https://github.com/xgfone/go-linux-namespace/actions/workflows/go.yml/badge.svg)](https://github.com/xgfone/go-linux-namespace/actions/workflows/go.yml) [![GoDoc](https://pkg.go.dev/badge/github.com/xgfone/go-namespace)](https://pkg.go.dev/github.com/xgfone/go-namespace) [![License](https://img.shields.io/badge/License-Apache%202.0-blue.svg?style=flat-square)](https://raw.githubusercontent.com/xgfone/go-namespace/master/LICENSE)
The operation about linux namespace. Support `Go1.7+`.
## Installation
```shell
$ go get -u github.com/xgfone/go-linux-namespace
```## Example
```go
package mainimport (
"fmt""github.com/xgfone/go-linux-namespace"
)func main() {
ns := NewNameSpace("name")// Ensure that the namespace exists.
if exist, err := ns.IsExist(); err != nil {
fmt.Println(err)
return
} else if !exist {
if err := ns.Create(); err != nil {
fmt.Println(err)
return
}
}// Execute the command in the namespace.
if output, err := ns.Exec("ip", "a"); err != nil {
fmt.Println(err)
} else {
fmt.Println(output)
}// Delete the namespace.
if err := ns.Delete(); err != nil {
fmt.Println(err)
return
}
}
```