复制项目

This commit is contained in:
kim.dev.6789
2026-01-14 22:16:44 +08:00
parent e2577b8cee
commit e50142a3b9
691 changed files with 97009 additions and 1 deletions

View File

@@ -0,0 +1,26 @@
package main
import (
"fmt"
"os"
"github.com/shirou/gopsutil/mem"
)
func main() {
vMem, err := mem.VirtualMemory()
if err != nil {
fmt.Fprintf(os.Stderr, "Failed to get virtual memory info: %v\n", err)
os.Exit(1)
}
// Use the Available field to get the available memory
availableMemoryGB := float64(vMem.Available) / float64(1024*1024*1024)
if availableMemoryGB < 1.0 {
fmt.Fprintf(os.Stderr, "System available memory is less than 1GB: %.2fGB\n", availableMemoryGB)
os.Exit(1)
} else {
fmt.Printf("System available memory is sufficient: %.2fGB\n", availableMemoryGB)
}
}