<commit_before>package helpers

import (
	"io/ioutil"
	"golang.org/x/sys/unix"
)

// AgentVersion defines the build of
// the agent along with a short
// git hash of the point in the
// repo when the agent as built
var AgentVersion string = "UNSET"

// initrdReleaseFile defines the path
// to the file containing the Rebuild
// Initrd release version string
const initrdReleaseFile = "/lib/rebuild/initrd-release"

// GetInitrdVersion reads a file from
// the system that contains the version
// of the Rebuild Initrd this agent is
// running from
func GetInitrdVersion() (string, error) {
	ver, err := ioutil.ReadFile(initrdReleaseFile)

	return string(ver), err
}

// GetKernelVersion queries uname
// and returns the "Release" field
// as a string
func GetKernelVersion() (string, error){
	uname := unix.Utsname{}
	err := unix.Uname(&uname)

	if err != nil {
		return "", nil
	}

	releaseBytes := make([]byte, len(uname.Release))
	for i, v := range uname.Release {
		releaseBytes[i] = byte(v)
	}

	return string(releaseBytes), nil
}<commit_msg>Updated the #GetInitrdVersion helper so it will strip whitespaces from the output<commit_after>package helpers

import (
	"io/ioutil"
	"golang.org/x/sys/unix"
	"strings"
)

// AgentVersion defines the build of
// the agent along with a short
// git hash of the point in the
// repo when the agent as built
var AgentVersion string = "UNSET"

// initrdReleaseFile defines the path
// to the file containing the Rebuild
// Initrd release version string
const initrdReleaseFile = "/lib/rebuild/initrd-release"

// GetInitrdVersion reads a file from
// the system that contains the version
// of the Rebuild Initrd this agent is
// running from
func GetInitrdVersion() (string, error) {
	ver, err := ioutil.ReadFile(initrdReleaseFile)

	return strings.TrimSpace(string(ver)), err
}

// GetKernelVersion queries uname
// and returns the "Release" field
// as a string
func GetKernelVersion() (string, error){
	uname := unix.Utsname{}
	err := unix.Uname(&uname)

	if err != nil {
		return "", nil
	}

	releaseBytes := make([]byte, len(uname.Release))
	for i, v := range uname.Release {
		releaseBytes[i] = byte(v)
	}

	return string(releaseBytes), nil
}
{'fraction_non_alphanumeric': 0.11121239744758432, 'fraction_numerical': 0.0, 'mean_word_length': 3.9105145413870246, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4288780', 'n_tokens_mistral': 708, 'n_tokens_neox': 689, 'n_words': 246}