File: osinfo_windows.go

package info (click to toggle)
golang-github-blackfireio-osinfo 1.0.3-2
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, forky, sid, trixie
  • size: 100 kB
  • sloc: makefile: 2
file content (22 lines) | stat: -rw-r--r-- 417 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
package osinfo

import (
	"fmt"
	"os/exec"
	"strings"
)

func readCommandOutput(cmd string, arg ...string) (result string, err error) {
	command := exec.Command(cmd, arg...)
	var bytes []byte
	bytes, err = command.CombinedOutput()
	if err == nil {
		result = strings.TrimSpace(string(bytes))
	} else {
		if len(bytes) > 0 && err.Error() == "exit status 1" {
			err = fmt.Errorf("%v", string(bytes))
		}
	}

	return
}