cleanup of the code and add more data to config

This commit is contained in:
HikariKnight 2023-04-08 23:40:23 +02:00
parent c3be59660d
commit ef3760879b
6 changed files with 99 additions and 10 deletions

30
pkg/command/command.go Normal file
View file

@ -0,0 +1,30 @@
package command
import (
"bytes"
"io"
"os/exec"
)
func Run(binary string, args ...string) ([]string, error) {
var stdout, stderr bytes.Buffer
// Configure the ls-iommu c--ommand
cmd := exec.Command(binary, args...)
cmd.Stderr = &stderr
cmd.Stdout = &stdout
// Execute the command
err := cmd.Run()
// Read the output
output, _ := io.ReadAll(&stdout)
outerr, _ := io.ReadAll(&stderr)
outputs := []string{}
outputs = append(outputs, string(output))
outputs = append(outputs, string(outerr))
// Return our list of items
return outputs, err
}