Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/lorenzosaino/go-sysctl
Go wrapper around the sysctl interface
https://github.com/lorenzosaino/go-sysctl
go golang sysctl
Last synced: 5 days ago
JSON representation
Go wrapper around the sysctl interface
- Host: GitHub
- URL: https://github.com/lorenzosaino/go-sysctl
- Owner: lorenzosaino
- License: bsd-3-clause
- Created: 2018-03-30T23:32:05.000Z (over 6 years ago)
- Default Branch: main
- Last Pushed: 2023-04-09T17:06:21.000Z (over 1 year ago)
- Last Synced: 2024-10-19T01:32:33.767Z (18 days ago)
- Topics: go, golang, sysctl
- Language: Go
- Homepage:
- Size: 1.62 MB
- Stars: 53
- Watchers: 4
- Forks: 9
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
# Go Sysctl
[![GoDoc](https://img.shields.io/static/v1?label=godoc&message=reference&color=blue)](https://pkg.go.dev/github.com/lorenzosaino/go-sysctl)
[![Build](https://github.com/lorenzosaino/go-sysctl/workflows/Build/badge.svg)](https://github.com/lorenzosaino/go-sysctl/actions)
[![Go Report Card](https://goreportcard.com/badge/github.com/lorenzosaino/go-sysctl)](https://goreportcard.com/report/github.com/lorenzosaino/go-sysctl)
[![License](https://img.shields.io/github/license/lorenzosaino/go-sysctl.svg)](https://github.com/lorenzosaino/go-sysctl/blob/master/LICENSE)Go wrapper around the sysctl interface.
## Documentation
See [Go doc](https://pkg.go.dev/github.com/lorenzosaino/go-sysctl?tab=doc).
## Usage
```go
import sysctl "github.com/lorenzosaino/go-sysctl"var (
val string
vals map[string]string
err error
)// Get value of a single sysctl
// This is equivalent to running "sysctl "
val, err = sysctl.Get("net.ipv4.ip_forward")// Get the values of all sysctls matching a given pattern
// This is equivalent to running "sysctl -a -r "
vals, err = sysctl.GetPattern("net.ipv4.ipfrag")// Get the values of all sysctls
// This is equivalent to running "sysctl -a"
vals, err = sysctl.GetAll()// Set the value of a sysctl
// This is equivalent to running "sysctl -w ="
err = sysctl.Set("net.ipv4.ip_forward", "1")// Set sysctl values from configuration file
// This is equivalent to running "sysctl -p "
err = sysctl.LoadConfigAndApply("/etc/sysctl.conf")
```## License
[BSD 3-clause](LICENSE)