osrelease

package module
v0.0.0-...-bcdb4a3 Latest Latest
Warning

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

Go to latest
Published: May 22, 2019 License: Apache-2.0 Imports: 1 Imported by: 7

README

os-release

Build Status Go Report Card GoDoc

Parse and load OS identification data.

Usage

Example usage is show below.

package main

import (
	"fmt"
	"io/ioutil"

	osr "github.com/dominodatalab/os-release"
)

func main() {
	contents, err := ioutil.ReadFile("/etc/os-release")
	if err != nil {
		panic(err)
	}
	info := osr.Parse(string(contents))

	// Inspect the distro lineage
	fmt.Printf("Is %q like fedora? %t", info.Name, info.IsLikeFedora())
	fmt.Printf("Is %q like debian? %t", info.Name, info.IsLikeDebian())

	// List all of the fields on the Data struct, such as ID/Name/Version and others.
	fmt.Printf("%#v", info)
}

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Data

type Data struct {
	ID              string
	IDLike          string
	Name            string
	PrettyName      string
	Version         string
	VersionID       string
	VersionCodename string
}

Data exposes the most common identification parameters.

func Parse

func Parse(contents string) *Data

Parse expects the contents of /etc/os-release and populates the fields of a Data object.

func (*Data) IsCentOS

func (d *Data) IsCentOS() bool

IsCentOS will return true for CentOS.

func (*Data) IsLikeDebian

func (d *Data) IsLikeDebian() bool

IsLikeDebian will return true for Debian and any other related OS, such as Ubuntu.

func (*Data) IsLikeFedora

func (d *Data) IsLikeFedora() bool

IsLikeFedora will return true for Fedora and any other related OS, such as CentOS or RHEL.

func (*Data) IsRHEL

func (d *Data) IsRHEL() bool

IsRHEL will return true for RHEL OS.

func (*Data) IsUbuntu

func (d *Data) IsUbuntu() bool

IsUbuntu will return true for Ubuntu OS.

Jump to

Keyboard shortcuts

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