Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func DateConversion ¶
DateConversion takes a date string input and converts it to RFC3339 format. It attempts to parse the input date string using multiple common date formats and returns the formatted date as a string.
Parameters:
- data: A string representing a date in any common format
Returns:
- string: The date formatted in RFC3339 format (2006-01-02T15:04:05Z07:00)
- error: An error if the date parsing fails, nil otherwise
func GetHostname ¶
GetHostname retrieves the hostname of the system by reading the /etc/hostname file. It returns the hostname as a string and any error encountered during the process. The hostname is trimmed of leading/trailing whitespace before being returned. If the file cannot be read, it returns an empty string and an error with details.
func GetMachineId ¶
GetMachineId retrieves the unique machine identifier from the '/etc/machine-id' file. This identifier is typically used to distinguish the host machine in a network.
Returns:
- string: The machine ID as a trimmed string
- error: An error if reading the machine-id file fails
func PackageBinary ¶
func PackageBinary() string
PackageBinary determines and verifies the appropriate package manager binary (yum or dnf) based on the Linux distribution version. It reads /etc/os-release to check if the system is running RHEL/CentOS 8 or 9, in which case it selects 'dnf' instead of the default 'yum'.
The function also verifies if the selected package manager is installed in the system. If the binary is not found, it exits with an error message.
Returns:
- string: The name of the package manager binary ("yum" or "dnf")
The function will exit with status code 1 if the required package manager is not installed.
func SplitPackageName ¶
SplitPackageName splits a RPM package name into its components. It takes a package name string as input and returns the following components:
- name: The name of the package
- version: The version number
- release: The release number
- epoch: The epoch number (empty string if not present)
- arch: The architecture
The function expects package names in the following format: [name]-[version]-[release].[arch].rpm or [name]-[epoch]:[version]-[release].[arch].rpm
The .rpm suffix is optional and will be trimmed if present. If epoch is not present in the package name, an empty string is returned for that component.
Types ¶
This section is empty.