x/sys/windows/registry: Compile on MacOSX?

833 views
Skip to first unread message

andy.g...@gmail.com

unread,
Feb 18, 2016, 12:47:24 PM2/18/16
to golang-nuts
Hey,

i am in the progress of writing a small helper tool that need to run on MacOSX, Linux and Windows.
On MacOSX and Linux i need to access some files.
On Windows i need to read a value from a registry.
For this i want to use the golang.org/x/sys/windows/registry package.

So i have something like

switch runtime.GOOS {
case "darwin":
...
case "linux":
...
case "windows":
...
}

in my code.
Everything works fine for darwin and linux.
But when i start to developing with golang.org/x/sys/windows/registry on MacOSX i am not able to compile / get the code by go get:

can't load package: package golang.org/x/sys/windows/registry: no buildable Go source files in /Users/agrunwald/Development/Go/src/golang.org/x/sys/windows/registry

I am developing this app on MacOSX.
Am i right that i only able to compile this app on a windows machine?
Or is there a trick i miss?

Thanks,
Andy

andy.g...@gmail.com

unread,
Feb 18, 2016, 1:31:50 PM2/18/16
to golang-nuts, andy.g...@gmail.com
Okay. In the meantime i found one solution: Using Build Constraints.


Any other solution?

James Bardin

unread,
Feb 18, 2016, 1:40:58 PM2/18/16
to golang-nuts, andy.g...@gmail.com


On Thursday, February 18, 2016 at 1:31:50 PM UTC-5, andy.g...@gmail.com wrote:
Okay. In the meantime i found one solution: Using Build Constraints.


Any other solution?


Nope, you need to use build constraints, and build for target platform. Just switching on GOOS doesn't help when the code for other platforms can't be compiled at all. 
Reply all
Reply to author
Forward
0 new messages