pbnjay / memory

A go function to report total system memory

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Return an error instead of 0

NatoBoram opened this issue · comments

https://godoc.org/github.com/pbnjay/memory#TotalMemory
If accessible memory size could not be determined, then 0 is returned.

Wouldn't it be more idiomatic to return an error instead?

Yes, but since it's only an advisory function there's not much utility to be gained. I've only ever needed to know if it worked or not. I think most people interested in the error details would be accessing the sysctl's directly anyway.