summaryrefslogtreecommitdiff
path: root/vendor/github.com/Microsoft/hcsshim/osversion/osversion_windows.go
diff options
context:
space:
mode:
Diffstat (limited to 'vendor/github.com/Microsoft/hcsshim/osversion/osversion_windows.go')
-rw-r--r--vendor/github.com/Microsoft/hcsshim/osversion/osversion_windows.go28
1 files changed, 18 insertions, 10 deletions
diff --git a/vendor/github.com/Microsoft/hcsshim/osversion/osversion_windows.go b/vendor/github.com/Microsoft/hcsshim/osversion/osversion_windows.go
index 42e58403d..3ab3bcd89 100644
--- a/vendor/github.com/Microsoft/hcsshim/osversion/osversion_windows.go
+++ b/vendor/github.com/Microsoft/hcsshim/osversion/osversion_windows.go
@@ -2,6 +2,7 @@ package osversion
import (
"fmt"
+ "sync"
"golang.org/x/sys/windows"
)
@@ -15,19 +16,26 @@ type OSVersion struct {
Build uint16
}
+var (
+ osv OSVersion
+ once sync.Once
+)
+
// Get gets the operating system version on Windows.
// The calling application must be manifested to get the correct version information.
func Get() OSVersion {
- var err error
- osv := OSVersion{}
- osv.Version, err = windows.GetVersion()
- if err != nil {
- // GetVersion never fails.
- panic(err)
- }
- osv.MajorVersion = uint8(osv.Version & 0xFF)
- osv.MinorVersion = uint8(osv.Version >> 8 & 0xFF)
- osv.Build = uint16(osv.Version >> 16)
+ once.Do(func() {
+ var err error
+ osv = OSVersion{}
+ osv.Version, err = windows.GetVersion()
+ if err != nil {
+ // GetVersion never fails.
+ panic(err)
+ }
+ osv.MajorVersion = uint8(osv.Version & 0xFF)
+ osv.MinorVersion = uint8(osv.Version >> 8 & 0xFF)
+ osv.Build = uint16(osv.Version >> 16)
+ })
return osv
}