<commit_before>package main

// `biosinfo` represent the computer informations
type biosinfo struct {
	motherboard  string
	productName  string
	serialNumber string //TODO will probably not be available without root
	BIOS         string
	BIOSVersion  string
}

// Get informations about the BIOS (or UEFI)
func getBIOSinfo() biosinfo {
	result := biosinfo{
		motherboard:  "",
		productName:  "",
		serialNumber: "",
		BIOS:         "",
		BIOSVersion:  "",
	}
	return result
}

//TODO read directly from   /sys/devices/virtual/dmi/id/* /sys/class/dmi/id/* on linux to avoid demidecode sudo problem
//or try lshal see http://stackoverflow.com/questions/20206474/extract-the-linux-serial-number-without-sudo
//or dmesg ?
//TODO use `sysctl` and/or kenv interfaces`on BSD
//TODO use `system_profiler` on osx
//TODO use `wmic bios get smbiosbiosversion` on windows<commit_msg>Update biosinfo stats<commit_after>package main

import (
	"io/ioutil"
	"strings"
)

// `biosinfo` represent the computer motherboard and bios informations
type biosinfo struct {
	boardName   string // name of the motherboard ex. 'C-64'
	boardVendor string // name of the motherboard  vendor ex. 'Commodore'
	biosVendor  string // name of the BIOS editor ex. 'Coreboot'
	biosVersion string // version of the BIOS
	biosDate    string // release date of the BIOS
}

// Get informations about the BIOS (or UEFI)
// we prefer to read directly from `/sys/devices/virtual/dmi/id/` than `demidecode` to avoid `sudo`
func getBIOSinfo() biosinfo {
	boardname, err := ioutil.ReadFile("/sys/devices/virtual/dmi/id/board_name")
	if err != nil {
		panic(err) //TODO do not panic but manage the error
	}
	boardvendor, err := ioutil.ReadFile("/sys/devices/virtual/dmi/id/board_vendor")
	if err != nil {
		panic(err) //TODO do not panic but manage the error
	}
	biosvendor, err := ioutil.ReadFile("/sys/devices/virtual/dmi/id/bios_vendor")
	if err != nil {
		panic(err) //TODO do not panic but manage the error
	}
	biosversion, err := ioutil.ReadFile("/sys/devices/virtual/dmi/id/bios_version")
	if err != nil {
		panic(err) //TODO do not panic but manage the error
	}
	biosdate, err := ioutil.ReadFile("/sys/devices/virtual/dmi/id/bios_date")
	if err != nil {
		panic(err) //TODO do not panic but manage the error
	}

	result := biosinfo{
		boardName:   strings.TrimRight(string(boardname), "\n"), // Trimright remove the EOF carriage return
		boardVendor: strings.TrimRight(string(boardvendor), "\n"),
		biosVendor:  strings.TrimRight(string(biosvendor), "\n"),
		biosVersion: strings.TrimRight(string(biosversion), "\n"),
		biosDate:    strings.TrimRight(string(biosdate), "\n"),
	}
	return result
}

//TODO use `sysctl` and/or kenv interfaces`on BSD
//TODO use `system_profiler` on osx
//TODO use `wmic bios get smbiosbiosversion` on windows
// We do not ask for the board serial number because it need `sudo` on Linux
// and because it's rarely usefull to look at it on a 'quick' way
{'fraction_non_alphanumeric': 0.11616847826086957, 'fraction_numerical': 0.0033967391304347825, 'mean_word_length': 3.8199672667757776, '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': '5764383', 'n_tokens_mistral': 1031, 'n_tokens_neox': 987, 'n_words': 313}