system

package
v0.0.1-pre1 Latest Latest
Warning

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

Go to latest
Published: Apr 2, 2025 License: Apache-2.0 Imports: 6 Imported by: 1 module, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

View Source
const (
	OSWindows = "windows"
	OSLinux   = "linux"
	OSDarwin  = "darwin"
	OSFreeBSD = "freebsd"
	OSNetBSD  = "netbsd"
	OSIllumos = "illumos"
	OSSolaris = "solaris"
	OSOpenBSD = "openbsd"

	// OS Aliases
	OSMacOS = "macos"
	OSX     = "osx"

	// Base arches
	ArchX8664     = "x86_64"
	Arch386       = "386"
	ArchArm       = "arm"
	ArchArm64     = "arm64"
	ArchRiscV64   = "riscv64"
	ArchUniversal = "universal"

	// Not supported
	ArchS390X   = "s390x"   // IBM Z
	ArchPPC64LE = "ppc64le" // IBM Power (redhat naming)
	ArchPPC64EL = "ppc64el" // IBM Power (debian naming)
	ArchPPC64   = "ppc64"

	// Aliases
	ArchArmHF   = "armhf"
	ArchArmV7   = "armv7"
	ArchArmV7HL = "armv7hl"
	ArchAarch64 = "aarch64"
	ArchAMD64   = "amd64"
	ArchX86     = "x86"
	ArchI686    = "i686"
	ArchI386    = "i386"
	Arch32Bit   = "32bit"
	Arch64Bit   = "64bit"
	ArchX64     = "x64"
)

Platform constants

View Source
const (
	PackageRPM = "rpm"
	PackageDeb = "deb"
	PackageApk = "apk"
	PackageDmg = "dmg"
	PackageMSI = "msi"
	PackageWhl = "whl" // Python wheel

	ArchiveZip = "zip"
	ArchiveTar = "tar"
	ArchiveBz2 = "bz2"
	ArchiveGz  = "gz"
	ArchiveXz  = "xz"
	ArchiveRar = "rar"
	ArchiveL7  = "l7"
	ArchiveTgz = "tgz"
	Archive7z  = "7z"
)

Recognized package types

Variables

View Source
var ArchAliases = map[string]LabelList{
	ArchX8664:   {ArchX8664, ArchAMD64, Arch64Bit, ArchX64, ArchX86},
	ArchArm64:   {ArchArm64, ArchAarch64},
	ArchArm:     {ArchArm, ArchArmHF, ArchArmV7, ArchArmV7HL},
	Arch386:     {Arch386, ArchI686, ArchI386, Arch32Bit},
	ArchRiscV64: {ArchRiscV64},
	ArchS390X:   {ArchS390X},
	ArchPPC64LE: {ArchPPC64LE, ArchPPC64EL, ArchPPC64},
}

Arch alias maps

View Source
var ArchiveExtensions = ExtensionList{
	ArchiveZip: {"zip"},
	ArchiveTar: {"tar"},
	ArchiveBz2: {"bz2", "bz"},
	ArchiveGz:  {"gz"},
	ArchiveXz:  {"xz"},
	ArchiveRar: {"rar"},
	ArchiveL7:  {"l7"},
	ArchiveTgz: {"tar.gz", "tgz"},
	Archive7z:  {"7z"},
}
View Source
var (
	FilenameSeparators = map[string]string{
		"-": "-", "_": "_", ".": ".",
	}
)
View Source
var OSAliases = map[string]LabelList{
	OSLinux:   {OSLinux},
	OSWindows: {OSWindows},
	OSDarwin:  {OSDarwin, OSMacOS, OSX},
	OSFreeBSD: {OSFreeBSD},
	OSNetBSD:  {OSNetBSD},
	OSIllumos: {OSIllumos},
	OSSolaris: {OSSolaris},
	OSOpenBSD: {OSOpenBSD},
}

OS alias maps

View Source
var PackageExtensions = ExtensionList{
	PackageRPM: {"rpm"},
	PackageDeb: {"deb"},
	PackageApk: {"apk"},
	PackageDmg: {"dmg"},
	PackageMSI: {"msi"},
	PackageWhl: {"whl"},
}

Functions

func GetArch

func GetArch(label string) string

GetArch returns the "official" (according to this library) arch label from a string. If it does not match one of the known aliases it returns an empty string

func GetOS

func GetOS(label string) string

GetOS returns the "official" (according to this library) Os label from a string. If it does not match one of the known aliases it returns an empty string

func IsArchive

func IsArchive(filename string) bool

IsArchive takes a filename and returns true if it matches a known archive type

func IsPackage

func IsPackage(filename string) bool

IsPackage takes a filename and returns true if it matches a known package type

func MainSplitPattern

func MainSplitPattern() string

MainSplitPattern dynamically builds a regex pattern with the know OS and arch patterns to split and parse filenames to deduct platform, kind and other data.

Types

type ExtensionList

type ExtensionList map[string][]string

func (*ExtensionList) GetTypeExtensionFromFile

func (el *ExtensionList) GetTypeExtensionFromFile(filename string) (fileType, extension string)

func (*ExtensionList) GetTypeFromFile

func (el *ExtensionList) GetTypeFromFile(filename string) string

type Info

type Info struct {
	Os   string
	Arch string
}

func GetInfo

func GetInfo() (*Info, error)

GetInfo returns information about the running system

type LabelList

type LabelList []string

LabelList is a list of os or arch labels.

func (*LabelList) ToRegex

func (ll *LabelList) ToRegex() *regexp.Regexp

Jump to

Keyboard shortcuts

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