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 ¶
- Variables
- func Is32Bit() (bool, error)
- type ArchInfo
- type Architecture
- func (a *Architecture) Is(other Architecture) bool
- func (a *Architecture) Is64Bit() bool
- func (a *Architecture) IsCompatibleWith(other Architecture) bool
- func (a *Architecture) IsUnset() bool
- func (a *Architecture) Parse(name string) error
- func (a Architecture) String() string
- func (a *Architecture) To32BitUserLand()
- type Distribution
- type DistroInfo
- type Extension
- type Library
- type LibraryInfo
- type OS
- type OSInfo
Constants ¶
This section is empty.
Variables ¶
var ErrParse = errors.New("unable to parse")
ErrParse is returned when a propery cannot be parsed.
Functions ¶
Types ¶
type ArchInfo ¶
ArchInfo holds information about an architecture type, including aliases and a parse function.
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 ¶
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 ¶
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 ¶
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.
type Library ¶
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) IsCompatibleWith ¶
IsCompatibleWith checks if this library is compatible with another.
type LibraryInfo ¶
LibraryInfo holds information about a library type, including aliases.
func (LibraryInfo) Supported ¶
func (LibraryInfo) Supported() []LibraryInfo
Supported returns a slice of supported library information.