platform

package
v0.0.3 Latest Latest
Warning

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

Go to latest
Published: Mar 12, 2025 License: MIT Imports: 8 Imported by: 0

Documentation

Overview

Package platform provides types and utilities for representing and working with different system platforms, including architectures, operating systems, libraries, and distributions. It allows for parsing, compatibility checks, and setting defaults for various platform components such as OS, architecture, library, and file extensions.

Index

Constants

This section is empty.

Variables

View Source
var ErrParse = errors.New("unable to parse")

ErrParse is returned when a propery cannot be parsed.

Functions

func Is32Bit

func Is32Bit() (bool, error)

Is32Bit returns true if the system is running in 32-bit mode.

Types

type ArchInfo

type ArchInfo struct {
	Type    string
	Aliases []string
	Parse   func(string) (int, error)
}

ArchInfo holds information about an architecture type, including aliases and a parse function.

func (ArchInfo) Supported

func (ArchInfo) Supported() []ArchInfo

Supported returns a slice of supported architecture information.

type Architecture

type Architecture struct {
	Type            string
	Version         int
	Raw             string // Original parsed architecture value
	Is32BitUserLand bool
}

Architecture represents a CPU architecture with its type, version, and raw string.

func (*Architecture) Is

func (a *Architecture) Is(other Architecture) bool

Is checks if this architecture is exactly the same as another.

func (*Architecture) Is64Bit

func (a *Architecture) Is64Bit() bool

Is64Bit returns true if the architecture is 64-bit.

func (*Architecture) IsCompatibleWith

func (a *Architecture) IsCompatibleWith(other Architecture) bool

IsCompatibleWith checks if this architecture is compatible with another.

func (*Architecture) IsUnset

func (a *Architecture) IsUnset() bool

IsUnset returns true if the architecture type is not set.

func (*Architecture) Parse

func (a *Architecture) Parse(name string) error

Parse attempts to parse the architecture from the given name string.

func (Architecture) String

func (a Architecture) String() string

String returns a string representation of the architecture.

func (*Architecture) To32BitUserLand

func (a *Architecture) To32BitUserLand()

To32BitUserLand converts 64-bit architecture to 32-bit equivalent.

type Distribution

type Distribution struct {
	Type string
	Raw  string // Original parsed distribution value
}

Distribution represents a Linux distribution.

func Default

func Default() Distribution

Default returns the default Distribution, which is an empty Distribution.

func (Distribution) Is

func (d Distribution) Is(other Distribution) bool

Is checks if this distribution is exactly the same as another.

func (Distribution) IsCompatibleWith

func (d Distribution) IsCompatibleWith(other Distribution) bool

IsCompatibleWith checks if this distribution is compatible with another.

func (Distribution) IsUnset

func (d Distribution) IsUnset() bool

IsUnset returns true if the distribution type is not set.

func (*Distribution) Parse

func (d *Distribution) Parse(name string) error

Parse attempts to parse the distribution from the given name string.

func (Distribution) String

func (d Distribution) String() string

String returns a string representation of the distribution.

type DistroInfo

type DistroInfo struct {
	Type    string
	Aliases []string
}

DistroInfo holds information about a distribution type, including aliases.

func (DistroInfo) Supported

func (DistroInfo) Supported() []DistroInfo

Supported returns a slice of supported distribution information.

type Extension

type Extension string

Extension represents a file extension, typically used for executable files on different operating systems.

func (*Extension) Default

func (e *Extension) Default(os OS) Extension

Default returns the default file extension based on the operating system. For Windows, it returns ".exe", and for other operating systems, it returns an empty string.

func (*Extension) Parse

func (e *Extension) Parse(name string) error

Parse extracts the file extension from a given filename.

func (Extension) String

func (e Extension) String() string

String returns the Extension as a string.

type Library

type Library struct {
	Type string
	Raw  string // Original parsed library value
}

Library represents a system library or ABI (Application Binary Interface).

func (*Library) Default

func (l *Library) Default(os OS, distro Distribution) Library

Default returns the default Library for a given OS and Distribution.

func (Library) Is

func (l Library) Is(other Library) bool

Is checks if this library is exactly the same as another.

func (Library) IsCompatibleWith

func (l Library) IsCompatibleWith(other Library) bool

IsCompatibleWith checks if this library is compatible with another.

func (Library) IsUnset

func (l Library) IsUnset() bool

IsUnset returns true if the library type is not set.

func (*Library) Parse

func (l *Library) Parse(name string) error

Parse attempts to parse the library from the given name string.

func (Library) String

func (l Library) String() string

String returns a string representation of the library.

type LibraryInfo

type LibraryInfo struct {
	Type    string
	Aliases []string
}

LibraryInfo holds information about a library type, including aliases.

func (LibraryInfo) Supported

func (LibraryInfo) Supported() []LibraryInfo

Supported returns a slice of supported library information.

type OS

type OS struct {
	Type string
	Raw  string // Original parsed OS value
}

OS represents an operating system.

func (*OS) Is

func (o *OS) Is(other OS) bool

Is checks if this OS is exactly the same as another.

func (*OS) IsCompatibleWith

func (o *OS) IsCompatibleWith(other OS) bool

IsCompatibleWith checks if this OS is compatible with another.

func (*OS) IsUnset

func (o *OS) IsUnset() bool

IsUnset returns true if the OS type is not set.

func (*OS) Parse

func (o *OS) Parse(name string) error

Parse attempts to parse the OS from the given name string.

func (OS) String

func (o OS) String() string

String returns a string representation of the OS.

type OSInfo

type OSInfo struct {
	Type    string
	Aliases []string
}

OSInfo holds information about an OS type, including aliases.

func (OSInfo) Supported

func (OSInfo) Supported() []OSInfo

Supported returns a slice of supported operating system information.

Jump to

Keyboard shortcuts

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