You can use the runtime and os packages in Go to get the system's total memory. Here's an example:
main.go290 chars17 linesIn this example, we're using the Sysinfo function from the syscall package to get information about the system. We're then using the Totalram and Unit fields from the Sysinfo_t struct to calculate the total memory in bytes. Finally, we're printing out the total memory using fmt.Printf.
gistlibby LogSnag