1
0
Fork 0
mirror of https://github.com/imjasonh/osversion synced 2026-07-07 03:02:18 +00:00
No description
Find a file
2022-02-15 11:18:47 -05:00
.github/workflows fix fix fix 2022-02-15 11:08:12 -05:00
cmd initial commit 2022-02-15 10:57:33 -05:00
go.mod initial commit 2022-02-15 10:57:33 -05:00
go.sum initial commit 2022-02-15 10:57:33 -05:00
LICENSE add README 2022-02-15 11:15:31 -05:00
osversion.go initial commit 2022-02-15 10:57:33 -05:00
osversion_windows.go fix fix fix 2022-02-15 11:08:12 -05:00
README.md fix link 2022-02-15 11:18:47 -05:00

osversion

e2e test

This repo contains a minimal library for detecting the current Windows version at runtime.

It's based on similar code in Kubernetes, itself seemingly based on this StackOverflow answer, without requiring the large dependency on Kubernetes, and with end-to-end tests using GitHub Actions.

It has a single dependency on x/sys/windows/registry.

Its intended use is to be able to match OCI container image manifests with a platform value that specifies an os.version, so that the correct image can be selected, taking into account the Windows OS version.

Usage

import "github.com/imjasonh/osversion"

...
fmt.Printf("The current osversion is %q", osversion.Get())
...

When this package is used on Windows, osversion.Get returns a string like "10.0.17763", depending on the current Windows version.

If this package is used on any non-Windows OS, osversion.Get returns an empty string.

See end-to-end test config to see expected values for different Windows versions.