github.com/lacework-dev/go-moby@v20.10.12+incompatible/pkg/parsers/operatingsystem/operatingsystem_unix.go (about) 1 // +build freebsd darwin 2 3 package operatingsystem // import "github.com/docker/docker/pkg/parsers/operatingsystem" 4 5 import ( 6 "bytes" 7 "errors" 8 9 "golang.org/x/sys/unix" 10 ) 11 12 // GetOperatingSystem gets the name of the current operating system. 13 func GetOperatingSystem() (string, error) { 14 utsname := &unix.Utsname{} 15 if err := unix.Uname(utsname); err != nil { 16 return "", err 17 } 18 return string(utsname.Machine[:bytes.IndexByte(utsname.Sysname[:], 0)]), nil 19 } 20 21 // GetOperatingSystemVersion gets the version of the current operating system, as a string. 22 func GetOperatingSystemVersion() (string, error) { 23 // there's no standard unix way of getting this, sadly... 24 return "", errors.New("Unsupported on generic unix") 25 } 26 27 // IsContainerized returns true if we are running inside a container. 28 // No-op on FreeBSD and Darwin, always returns false. 29 func IsContainerized() (bool, error) { 30 // TODO: Implement jail detection for freeBSD 31 return false, errors.New("Cannot detect if we are in container") 32 }