util

package
v0.0.0-...-f3abbe6 Latest Latest
Warning

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

Go to latest
Published: Sep 27, 2020 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Info

type Info struct {
	ID           string
	Version      string
	VersionParts version
	Like         string
	Codename     string
}

Info encompasses most of the information in this library in a single struct.

type LinuxDistributionObject

type LinuxDistributionObject struct {
	OsReleaseFile     string
	DistroReleaseFile string
	OsReleaseInfo     map[string]string
	LSBReleaseInfo    map[string]string
	DistroReleaseInfo map[string]string
}

LinuxDistributionObject is the base struct

func LinuxDistribution

func LinuxDistribution(d *LinuxDistributionObject) *LinuxDistributionObject

LinuxDistribution instantiates a LinuxDistributionObject and returns it after having parsed all relevant information.

func (*LinuxDistributionObject) BuildNumber

func (d *LinuxDistributionObject) BuildNumber(best bool) string

BuildNumber returns the build number of the distribution. See `Version` for information on `best`

func (*LinuxDistributionObject) Codename

func (d *LinuxDistributionObject) Codename() string

Codename returns the distribution's codename. Not every distrubtion has a codename, and sometimes, even if a codename is found it will not necessarily really be a valid codename but rather an identifier of its architecture (like in OpenSUSE's case which returns `x86_64`). Codenames should NEVER be used to identify a distribution's version. That's what `Version` is for.

func (*LinuxDistributionObject) GetDistroReleaseFileInfo

func (d *LinuxDistributionObject) GetDistroReleaseFileInfo() map[string]string

GetDistroReleaseFileInfo retrieves parsed information from an `lsb_release -a` command and returns a map with its key-value's

func (*LinuxDistributionObject) GetLSBReleaseInfo

func (d *LinuxDistributionObject) GetLSBReleaseInfo() map[string]string

GetLSBReleaseInfo retrieves parsed information from an `lsb_release -a` command and returns a map with its key-value's

func (*LinuxDistributionObject) GetOSReleaseFileInfo

func (d *LinuxDistributionObject) GetOSReleaseFileInfo() map[string]string

GetOSReleaseFileInfo retrieves parsed information from an os-release file and returns a map with its key-value's

func (*LinuxDistributionObject) ID

ID returns the id of the distribution.

func (*LinuxDistributionObject) Info

func (d *LinuxDistributionObject) Info(pretty bool, best bool) *Info

Info returns the Info struct.

func (*LinuxDistributionObject) Like

func (d *LinuxDistributionObject) Like() string

Like returns the ID_LIKE field of an os-release file if applicable. For example, this will return `rhel fedora` for centos or `arch` for Antergos.

func (*LinuxDistributionObject) MajorVersion

func (d *LinuxDistributionObject) MajorVersion(best bool) string

MajorVersion returns the major version of the distribution. See `Version` for information on `best`

func (*LinuxDistributionObject) MinorVersion

func (d *LinuxDistributionObject) MinorVersion(best bool) string

MinorVersion returns the minor version of the distribution. See `Version` for information on `best`

func (*LinuxDistributionObject) Name

func (d *LinuxDistributionObject) Name(pretty bool) string

Name returns the name of the distribution. Passing `pretty` as true will return the pretty name

func (*LinuxDistributionObject) Version

func (d *LinuxDistributionObject) Version(pretty bool, best bool) string

Version returns the version of the distribution Passing `pretty` as true will return the pretty name Passing `best` as true will return the best and more verbose result found between all levels of hierarchy instead of just the first one found.

func (*LinuxDistributionObject) VersionParts

func (d *LinuxDistributionObject) VersionParts(best bool) (string, string, string)

VersionParts returns three values, one for each part of a distribution's version. See `Version` for information on `best`

Jump to

Keyboard shortcuts

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