osrelease
A Go package to make reading in os-release files easy.
See https://www.freedesktop.org/software/systemd/man/os-release.html
Installation
$ go get github.com/cobaugh/osrelease
Usage
See godoc
package main
import (
"fmt"
"github.com/cobaugh/osrelease"
)
func main() {
fmt.Printf("EtcOsRelease = %v\n", osrelease.EtcOsRelease)
fmt.Printf("UsrLibOsRelease = %v\n", osrelease.UsrLibOsRelease)
osrelease, err := osrelease.Read()
if err != nil {
fmt.Printf("Error: %v\n", err)
return
}
fmt.Printf("PRETTY_NAME = %v\n", osrelease["PRETTY_NAME"])
osrelease, err = osrelease.ReadFile("/etc/os-release")
if err != nil {
fmt.Printf("Error: %v\n", err)
return
}
fmt.Printf("PRETTY_NAME = %v\n", osrelease["PRETTY_NAME"])
}
Output:
$ ./examples
EtcOsRelease = /etc/os-release
UsrLibOsRelease = /usr/lib/os-release
PRETTY_NAME = void
PRETTY_NAME = void```