Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/shaozi/gobrctl
A go library to get the list of bridges in Linux, same as `brctl show`
https://github.com/shaozi/gobrctl
Last synced: 9 days ago
JSON representation
A go library to get the list of bridges in Linux, same as `brctl show`
- Host: GitHub
- URL: https://github.com/shaozi/gobrctl
- Owner: shaozi
- License: bsd-2-clause
- Created: 2021-06-17T16:57:50.000Z (over 3 years ago)
- Default Branch: main
- Last Pushed: 2021-06-17T22:40:53.000Z (over 3 years ago)
- Last Synced: 2024-10-11T12:48:48.975Z (about 1 month ago)
- Language: Go
- Size: 6.84 KB
- Stars: 1
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Go Library to List Bridges in Linux
This is a go library that gets a list of bridges. The same as `brctl show`
## Installation
To install this package, you need to install Go and set your Go workspace first.
The first need Go installed (version 1.16+ is required), then you can use the below Go command to install gobrctl.
```sh
$ go get -u github.com/shaozi/gobrctl
```Import it in your code:
```go
import "github.com/shaozi/gobrctl"
```## Usage
```go
package mainimport (
"fmt"
"strings"
"github.com/shaozi/gobrctl"
)// simulate brctl show
func main() {
bridges := gobrctl.GetAllBridges()fmt.Println("bridge name bridge id STP enabled interfaces")
for _, bridge := range bridges {
var stpEnabled string
if bridge.Stp {
stpEnabled = "yes"
} else {
stpEnabled = "no"
}
fmt.Printf("%-16s%-20s%-16s%s\n", bridge.Name, bridge.Id, stpEnabled, strings.Join(bridge.Interfaces, ", "))
}
}```