lxn / win

A Windows API wrapper package for the Go Programming Language
Other
1.19k stars 313 forks source link

Feature Request: Server Core friendly modifications #23

Open someone1 opened 7 years ago

someone1 commented 7 years ago

Is it possible to disable parts of the wrapper for components that don't ship with Server Core installations of Windows, such as the opengl32 component?

See https://github.com/influxdata/telegraf/issues/1763 for a reason why this could be useful.

someone1 commented 7 years ago

Some guidance on how to detect if it is a server core installation:

https://msdn.microsoft.com/en-us/library/ee391629(v=vs.85).aspx https://blogs.technet.microsoft.com/server_core/2013/09/30/detecting-server-core-in-code/

Perhaps this change (although a breaking one) could be implemented rather than detecting supported libraries depending on the version of Windows:

Proposal

Instead of loading all libraries on import (via init()), the user must call on which APIs they want to load themselves. This would reduce the load time impact from the library and only keep active in memory parts of the Windows API the user wants to use.

The change would be simple: rename all the init() functions to Load<LibName>()

If the current branch is tagged as "v1" then this breaking change could be made "v2" and users can keep using this API by switching their imports to "gopkg.in/lxn/win.v1". Or a branch named "v2" can be introduced with this change so anyone that wants the "lazy load" feature can use the import path "gopkg.in/lxn/win.v2" with the only caveat being this wouldn't be the default interface going forward and any updates to the master branch would have to be pulled into the v2 branch.

JeffAshton commented 7 years ago

Feels like this library should just be broken apart instead of getting too fancy with detecting the core version.

JeffAshton commented 7 years ago

Hey guys, I pulled the Performance Data Helper wrapper into it's own library. @lxn would you be interested in taking ownership of this fork? Really it's your library, but just the PDH helpers. Sounds like you've already forked once from walk. :)

https://github.com/JeffAshton/win_pdh

thecloudtaylor commented 6 years ago

With Windows Server version 1709 Server Core is the only host now, so this will be important (if it's not already addressed?).