How to determine the OS version in Go?

I am currently writing a REST API client, and I am trying to determine which OS the user is using to create a useful User Agent string. This will allow me (I hope) to make the right decisions about which OS I will have to support in the future.

What I would like to do is: create a line that looks something like this:

Linux / 1.3.2 OR Darwin / 1.3.2 OR Windows / 1.3.2

It should work through Linux / Mac / Windows.

I can currently get the type of OS (ex: 'linux' / 'windows' / 'darwin') using

runtime.GOOS

But I can not find a way to capture the main / minor / micro OS versions.

+4
source share
2 answers

Go google group, , . - , , .

P.S. User_Agent?

User-Agent:Mozilla/5.0 (Macintosh; Intel Mac OS X 10_10_1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/42.0.2311.135 Safari/537.36
+4

uname ( uname (2) syscall), POSIX, Linux MacOSX.

, ; BTW, Linux , , MacOSX, , libc (, , GO) , .

( - Windows, )

+1

All Articles