From 1206e7d15c56379bfff0fc6b58a6de81a9384611 Mon Sep 17 00:00:00 2001 From: marco Date: Mon, 15 Jul 2024 12:12:27 +0200 Subject: [PATCH] version/DetectOS() --- version/os.go | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) create mode 100644 version/os.go diff --git a/version/os.go b/version/os.go new file mode 100644 index 0000000..a725ad9 --- /dev/null +++ b/version/os.go @@ -0,0 +1,18 @@ +package version + +import ( + "github.com/blackfireio/osinfo" +) + +func DetectOS() (string, string) { + osInfo, err := osinfo.GetOSInfo() + if err != nil { + return System, "???" + } + + if osInfo.Name != "" && System == "docker" { + return osInfo.Name + " (docker)", osInfo.Version + } + + return osInfo.Name, osInfo.Version +}