Closed shirou closed 9 years ago
Using gopsutil would probably be the best option, as uname
is also OS dependent. gopsutil may be overkill for what we're trying to accomplish, but I suspect other uses for the library will be found later.
uname
system call and command is specified by POSIX and most UNIX-like OS include. Some options are different but -s
and -r
are common. see http://en.wikipedia.org/wiki/Uname.
My point was, osVersion in the agent.go should return "distribution version(ex: 14.10)" not "os kernel version (ex: 3.8.0-25)".
But I search UserAgent example one more time, it seems "os kernel version" is widely used. If so, uname -r
is the best solution I think.
@shirou how about give a patch?
@xiaods Thank you for the patch. As I said, uname is returns only the OS version, not distribution. But it's enough I think.
@shirou All honor is yours.
I'm probably missing something here, but what's wrong with using runtime.GOOS? (Also getting build failures in Mac OS over here...)
@mholt see my patch.
@xiaods I saw it, but I'm still not grasping its benefit over runtime.GOOS. Isn't uname still platform-dependent?
@mholt yes, you are right, use runtime.GOOS should be elegant way, need a patch refresh it.
Should be pretty simple. If I get a chance this week I'll look at it (but no promises: final exams are around the corner).
I wish I could be more help here, but I'm also tied up with work and family until after the holidays.
I wrote an another patch, without dependency on uname
command
i prefer this #7 patch.
My original concern is OS dependent. Thank you for the xiaods but I also prefer #7.
agent/agent.go uses syscall.Utsname{} https://github.com/headzoo/surf/blob/master/agent/agent.go#L363
But this is OS dependent. not working Darwin (go 1.3.1).
Please use uname command like
uname -s
for osName anduname -r
for osVersion.However, uname -r shows the 'linux' version. But from agent_test.go, an expected string is a distribution version like 14.04 for Ubuntu 14.04.
If you want to get a distribution version, you may use https://github.com/shirou/gopsutil and HostInfo().