diff options
| author | Jeff Carr <[email protected]> | 2025-10-07 09:01:54 -0500 |
|---|---|---|
| committer | Jeff Carr <[email protected]> | 2025-10-07 09:01:54 -0500 |
| commit | d110888f81e357010b71a0a0286ba298fcd452c5 (patch) | |
| tree | 1905eb28f1da7217b6e7217713bf97dc71b0b90f /distro.go | |
| parent | 920eb20a447e1b6c08f433ac1857263dc21da41d (diff) | |
moved to go.wit.com/lib/debian
Diffstat (limited to 'distro.go')
| -rw-r--r-- | distro.go | 61 |
1 files changed, 0 insertions, 61 deletions
diff --git a/distro.go b/distro.go deleted file mode 100644 index bbbdda3..0000000 --- a/distro.go +++ /dev/null @@ -1,61 +0,0 @@ -// Copyright 2024 WIT.COM Inc. - -package zoopb - -// simple stab at making a human readable distro name -// this is for displaying in a table in the zookeeper app -// it's just so you can easily see what machines in your grid are -// doing what - -import ( - "bufio" - "fmt" - "os" - "runtime" - "strings" -) - -func initDistro() string { - switch runtime.GOOS { - case "windows": - return "windows" - case "macos": - return "macos" - case "linux": - // Detect the Linux distribution - distro := detectDistro() - if distro == "" { - fmt.Println("Unable to detect Linux distribution.") - distro = "fixme" - } - - fmt.Printf("Detected distribution: %s\n", distro) - return distro - default: - return runtime.GOOS - } -} - -// detectDistro returns the Linux distribution name (if possible) -func detectDistro() string { - // Check if we're on Linux - - // Try to read /etc/os-release to determine the distro - file, err := os.Open("/etc/os-release") - if err != nil { - return "" - } - defer file.Close() - - scanner := bufio.NewScanner(file) - for scanner.Scan() { - line := scanner.Text() - if strings.HasPrefix(line, "ID=") { - parts := strings.SplitN(line, "=", 2) - if len(parts) == 2 { - return strings.Trim(parts[1], `"`) - } - } - } - return "" -} |
