operatingsystem_unix.go 608 B

12345678910111213141516171819202122232425
  1. // +build freebsd darwin
  2. package operatingsystem
  3. import (
  4. "errors"
  5. "os/exec"
  6. )
  7. // GetOperatingSystem gets the name of the current operating system.
  8. func GetOperatingSystem() (string, error) {
  9. cmd := exec.Command("uname", "-s")
  10. osName, err := cmd.Output()
  11. if err != nil {
  12. return "", err
  13. }
  14. return string(osName), nil
  15. }
  16. // IsContainerized returns true if we are running inside a container.
  17. // No-op on FreeBSD and Darwin, always returns false.
  18. func IsContainerized() (bool, error) {
  19. // TODO: Implement jail detection for freeBSD
  20. return false, errors.New("Cannot detect if we are in container")
  21. }