github.com/lyraproj/hiera@v1.0.0-rc4/session/plugintransport_windows.go (about) 1 // +build windows 2 3 package session 4 5 import ( 6 "golang.org/x/sys/windows/registry" 7 "strconv" 8 ) 9 10 // getDefaultPluginTransport returns the plugin transport method to use. 11 // For Windows this can be unix if the OS build is 17063 or above, 12 // otherwise tcp is used 13 // https://devblogs.microsoft.com/commandline/af_unix-comes-to-windows/ 14 func getDefaultPluginTransport() string { 15 if isBuild17063() { 16 return pluginTransportUnix 17 } 18 return pluginTransportTCP 19 } 20 21 // isBuild17063 gets the Windows build number from the registry 22 func isBuild17063() bool { 23 k, err := registry.OpenKey(registry.LOCAL_MACHINE, `SOFTWARE\Microsoft\Windows NT\CurrentVersion`, registry.READ) 24 if err != nil { 25 return false 26 } 27 defer k.Close() 28 s, _, err := k.GetStringValue("CurrentBuild") 29 if err != nil { 30 return false 31 } 32 ver, err := strconv.Atoi(s) 33 if err != nil { 34 return false 35 } 36 return ver >= 17063 37 }