https://github.com/jxsl13/osfacts
osfacts is a go library for detecting os information like os family, architecture, distribution and version.
https://github.com/jxsl13/osfacts
aix ansible darwin distribution distro facts go golang linux macos operating-system osinfo solaris version windows
Last synced: 3 months ago
JSON representation
osfacts is a go library for detecting os information like os family, architecture, distribution and version.
- Host: GitHub
- URL: https://github.com/jxsl13/osfacts
- Owner: jxsl13
- License: mit
- Created: 2023-01-06T15:07:46.000Z (about 3 years ago)
- Default Branch: master
- Last Pushed: 2024-05-06T06:01:08.000Z (almost 2 years ago)
- Last Synced: 2024-06-20T12:06:31.145Z (almost 2 years ago)
- Topics: aix, ansible, darwin, distribution, distro, facts, go, golang, linux, macos, operating-system, osinfo, solaris, version, windows
- Language: Go
- Homepage:
- Size: 73.2 KB
- Stars: 1
- Watchers: 2
- Forks: 0
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# osfacts
Small library that allows to detect system information like operating system, its version and distribution
### import
```shell
go get github.com/jxsl13/osfacts@latest
```
### example
```go
package main
import (
"encoding/json"
"fmt"
"github.com/jxsl13/osfacts/distro"
)
func main() {
o, err := distro.Detect()
if err != nil {
panic(err)
}
data, _ := json.MarshalIndent(o, "", " ")
fmt.Println(string(data))
}
```
### requirements
requires Linux kernel version 2.6.32 or newer, which is the smallest compilation target for Go.
This prevents us from running on pretty old operating systems like SLES 10 and older.
- SLES >= 11
## `distro` package
This package supports detecting different os families, architectures, distributions and distribution versions.
### supportes OS families
The `distro` package supports these families and detecting their distro (or os) version.
- aix (does not have distributions)
- darwin (different os names depending on version)
- linux (see below)
- solaris (see below)
- windows
### supported `linux` distributions
- Alpine Linux
- ALT Linux
- Amazon
- Arch Linux
- CentOS (and CentOS Stream, TencentOS)
- Clear Linux
- Cumulus Linux
- Debian
- Deepin
- Devuan
- Gentoo
- Linux Mint
- Mandriva
- OpenWrt
- Oracle Linux
- RHEL
- Slackware
- SMGL
- SUSE
- Ubuntu
- Uos
### supported `solaris` distributions
- NexentaOS
- OmniOS
- OpenIndiana
- SmartOS
- Solaris (= Oracle Solaris)
### `windows`
The windows versioning is the same as the version string provided by the `WinVer.exe`.