[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

replace github.com/jaypipes/ghw with stdlib and a 4liner #5

Open
majst01 opened this issue Mar 12, 2020 · 0 comments
Open

replace github.com/jaypipes/ghw with stdlib and a 4liner #5

majst01 opened this issue Mar 12, 2020 · 0 comments

Comments

@majst01
Copy link
Contributor
majst01 commented Mar 12, 2020

We use this external dependency just for the sake of gathering CPUCount and Memory, for CPUCount there is:

runtime.NumCPU

and for Memory we can copy the work of https://github.com/pbnjay/memory which gathers memory with a syscall like:

// +build linux

package memory

import "syscall"

func sysTotalMemory() uint64 {
	in := &syscall.Sysinfo_t{}
	err := syscall.Sysinfo(in)
	if err != nil {
		return 0
	}
	// If this is a 32-bit system, then these fields are
	// uint32 instead of uint64.
	// So we always convert to uint64 to match signature.
	return uint64(in.Totalram) * uint64(in.Unit)
}

should be sufficient for our usecase and removes one external dependency.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant