Query Windows-OS version.
package main
import (
"fmt"
"github.com/zetamatta/go-windows-osversion"
)
func main() {
v := osversion.Query()
fmt.Printf("Major=%d\n", v.Major)
fmt.Printf("Minor=%d\n", v.Minor)
fmt.Printf("BuildNumber=%d\n", v.Build)
fmt.Printf("PlatformId=%d\n", v.PlatformId)
}
On Windows 8.1
$ cmd\ver\ver.exe
Major=6
Minor=3
BuildNumber=9600
PlatformId=2
On Windows 10
$ cmd\ver\ver.exe
Major=10
Minor=0
BuildNumber=18363
PlatformId=2
On not Windows (for example, Linux)
$ ./cmd/ver/ver
Major=0
Minor=0
BuildNumber=0
PlatformId=0
This package uses RtlGetVersion API which does not depend on manifest files.