From f1fbf6fe9c5f3f35b90d4435e81f66dd0fd18ded Mon Sep 17 00:00:00 2001 From: Thelolguy1 Date: Mon, 16 Oct 2023 14:34:37 -0700 Subject: [PATCH] reportinfo.go: add more checks --- util/reportinfo.go | 21 ++++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) diff --git a/util/reportinfo.go b/util/reportinfo.go index 9da81e92..5e0177f4 100644 --- a/util/reportinfo.go +++ b/util/reportinfo.go @@ -5,6 +5,7 @@ This is only a prototype. We will collect CPU flags and check for AVX, distro, kernel, flatpak, and config. More features may be added at a later time... +Wael, if you would like to combine the file reading into a single function, that would be cool. - lunarlattice 10/16/23 */ @@ -19,8 +20,8 @@ import ( type SysInfo struct { CPUFlags string AVXAvailable bool - Distro string - Kernel string + Distro string //Done + Kernel string // Done InFlatpak bool // Done Config string // Done } @@ -28,9 +29,23 @@ func GenerateInfo(currentConfigurationPath string) (SysInfo, error){ //TODO, returns struct Sysinfo. currentSystem := &SysInfo{} + // Get Distro + if distro, err := os.ReadFile("/etc/os-release"); err != nil { + return SysInfo{}, err + } else { + currentSystem.Distro = string(distro) + } + + // Get kernel + if kernel, err := os.ReadFile("/proc/version"); err != nil { + return SysInfo{}, err + } else { + currentSystem.Kernel = string(kernel) + } + // Read the config and store if config, err := os.ReadFile(currentConfigurationPath); err != nil { - return *currentSystem, err + return SysInfo, err } else { currentSystem.Config = string(config) }