osinfo

package module
v0.0.0-...-9e63396 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 5, 2021 License: MIT Imports: 8 Imported by: 2

README

osinfo

GitHub Go Reference Go Report Card Codacy Badge

What is osinfo?

OSinfo is a cross-platform OS Version collection tool. It is designed to unify multiple OS detection methods in a single module that can easily be integrated into other projects.

Officially Supported:
Windows MacOS Linux BSD
Windows Server 2012 10.6 - Snow Leopard Ubuntu FreeBSD
Windows Server 2016 10.7 - Lion Debian OpenBSD
Windows Server 2019 10.8 - Mountain Lion MXLinux
Windows 7 10.9 - Mavericks Mint
Windows 8 10.10 - Yosemite Kali
Windows 10 10.11 - El Capitan ParrotOS
10.12 - Sierra OpenSUSE Leap
10.13 - High Sierra OpenSUSE TumbleWeed
10.14 - Mojave OpenSUSE SLES
10.15 - Catalina Arch
11.0 - Big Sur Manjaro
Alpine
Fedora
RHEL
CentOS
Oracle

Example Usage

  1. Create fetchinfo.go
   package main

   import (
      "fmt"

      "github.com/JustinTimperio/osinfo"
   )

   func main() {
		release := osinfo.GetVersion()
		fmt.Printf(release.String())
	 }
  1. go mod init
  2. go mod tidy
  3. go run fetchinfo.go

Example Outputs

--------------------

Runtime: linux
Architecture: amd64
OS Name: Arch Linux
Version: rolling
Kernel: 5.11.2-arch1-1
Distro: arch
Package Manager: pacman

--------------------

Runtime: linux
Architecture: amd64
OS Name: Debian GNU/Linux 10 (buster)
Version: 10
Kernel: 4.19.0-13-amd64
Distro: debian
Package Manager: apt

--------------------

Runtime: windows
Architecture: amd64
OS Name: Windows Server 2016 Standard Evaluation
Version: 10
Build: 14393

--------------------

Runtime: darwin
Architecture: amd64
OS Name: Mac OS X
Version: 11.0.1
Version Name: MacOS - Big Sur 

--------------------

Runtime: freebsd
Architecture: amd64
OS Name: FreeBSD 12.1-RELEASE
Version: 12.1-RELEASE
Kernel: 1201000
Package Manger: pkg

--------------------

Runtime: openbsd 
Architecture: amd64
OS Name: OpenBSD 6.7 
Version: 6.7 
Kernel: GENERIC.MP#182 
Package Manger: pkg_add

--------------------

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Release

type Release struct {
	Runtime string
	Arch    string
	Name    string
	Version string
	Windows windowsRelease
	Linux   linuxRelease
	BSD     bsdRelease
	MacOs   macOsRelease
}

Release contains all the info about os in nested structs All values in the top level of the struct are guaranteed in the sense that they are always returned. Nested structs are only populated for the os they are compiled for IE: Release.Windows will only have values if you are on windows

func GetVersion

func GetVersion() Release

GetVersion Linux returns version info fetching os info for linux distros is more complicated process than it should be version information is collected via `uname` and `/etc/os-release` Returns:

  • r.Runtime
  • r.Arch
  • r.Name
  • r.Version
  • r.Linux.Kernel
  • r.Linux.Distro
  • r.Linux.PkgMng

func (*Release) String

func (r *Release) String() string

Provides a preformated print for every support OS

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL