diff options
| author | Jeff Carr <[email protected]> | 2025-10-07 07:13:29 -0500 |
|---|---|---|
| committer | Jeff Carr <[email protected]> | 2025-10-07 07:13:29 -0500 |
| commit | c5c6afea125875e635efb26da039d83d65e7d67f (patch) | |
| tree | 8fad7393e2c1f545b7c64e98fb0a919e20e6841c | |
| parent | 99f8eb08bdca46925e5a00d4dda4d9625694b86b (diff) | |
make this build on darwin
| -rw-r--r-- | apt.go | 27 | ||||
| -rw-r--r-- | hw.go | 6 | ||||
| -rw-r--r-- | hw_darwin.go | 7 | ||||
| -rw-r--r-- | hw_linux.go | 32 | ||||
| -rw-r--r-- | hw_windows.go | 7 | ||||
| -rw-r--r-- | wit.go | 7 |
6 files changed, 59 insertions, 27 deletions
@@ -2,9 +2,6 @@ package zoopb import ( "fmt" - "runtime" - - "golang.org/x/sys/unix" ) // init the installed package list @@ -38,27 +35,3 @@ func (me *Machine) addNew(name string, version string) { new1.Version = version me.Packages.Append(new1) } - -// simple memory and cpu count -func (me *Machine) getMemory() { - // Get number of CPUs - numCPUs := runtime.NumCPU() - - // Get total system memory - var sysInfo unix.Sysinfo_t - err := unix.Sysinfo(&sysInfo) - if err != nil { - fmt.Println("Error getting system info:", err) - return - } - - // Convert memory from bytes to GB - m := float64(sysInfo.Totalram) * float64(sysInfo.Unit) - me.Memory = int64(m) - me.Cpus = int64(numCPUs) - - // totalMemGB := float64(sysInfo.Totalram) * float64(sysInfo.Unit) / (1024 * 1024 * 1024) - // Print results - // fmt.Printf("Total Memory: %.2f GB\n", totalMemGB) - // fmt.Printf("Number of CPUs: %d\n", numCPUs) -} @@ -0,0 +1,6 @@ +package zoopb + +// init the installed package list +func (me *Machine) getMemory() { + me.osGetMemory() +} diff --git a/hw_darwin.go b/hw_darwin.go new file mode 100644 index 0000000..ab1aef8 --- /dev/null +++ b/hw_darwin.go @@ -0,0 +1,7 @@ +package zoopb + +// simple memory and cpu count +func (me *Machine) osGetMemory() { + me.Memory = int64(1024 * 1024) + me.Cpus = int64(1) +} diff --git a/hw_linux.go b/hw_linux.go new file mode 100644 index 0000000..d3cb116 --- /dev/null +++ b/hw_linux.go @@ -0,0 +1,32 @@ +package zoopb + +import ( + "fmt" + "runtime" + + "golang.org/x/sys/unix" +) + +// simple memory and cpu count +func (me *Machine) osGetMemory() { + // Get number of CPUs + numCPUs := runtime.NumCPU() + + // Get total system memory + var sysInfo unix.Sysinfo_t + err := unix.Sysinfo(&sysInfo) + if err != nil { + fmt.Println("Error getting system info:", err) + return + } + + // Convert memory from bytes to GB + m := float64(sysInfo.Totalram) * float64(sysInfo.Unit) + me.Memory = int64(m) + me.Cpus = int64(numCPUs) + + // totalMemGB := float64(sysInfo.Totalram) * float64(sysInfo.Unit) / (1024 * 1024 * 1024) + // Print results + // fmt.Printf("Total Memory: %.2f GB\n", totalMemGB) + // fmt.Printf("Number of CPUs: %d\n", numCPUs) +} diff --git a/hw_windows.go b/hw_windows.go new file mode 100644 index 0000000..ab1aef8 --- /dev/null +++ b/hw_windows.go @@ -0,0 +1,7 @@ +package zoopb + +// simple memory and cpu count +func (me *Machine) osGetMemory() { + me.Memory = int64(1024 * 1024) + me.Cpus = int64(1) +} @@ -5,6 +5,7 @@ import ( "os" "strings" + "go.wit.com/dev/davecgh/spew" "go.wit.com/lib/fhelp" ) @@ -127,6 +128,9 @@ func (m *Machine) InitWitMirrors() error { func (all *Packages) AddIfNewer(p *Package) { check := all.FindByName(p.Name) if check == nil { + if p.Name == "zood" { + spew.Dump(p) + } all.Append(p) return } @@ -137,6 +141,9 @@ func (all *Packages) AddIfNewer(p *Package) { return } if v1.LessThan(v2) { + if p.Name == "zood" { + spew.Dump(p) + } // log.Info("removing", v1, "using", v2) all.Delete(check) all.Append(p) |
