Navigation Menu

Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

undefined: registry.OpenKey when cross compiling on Windows for Linux #30927

Closed
TKSS3 opened this issue Mar 19, 2019 · 3 comments
Closed

undefined: registry.OpenKey when cross compiling on Windows for Linux #30927

TKSS3 opened this issue Mar 19, 2019 · 3 comments

Comments

@TKSS3
Copy link

TKSS3 commented Mar 19, 2019

What version of Go are you using (go version)?

$ go version
go version go1.11.5 windows/amd64

What operating system and processor architecture are you using (go env)?

go env Output
$ go env
GOARCH=amd64
GOHOSTARCH=amd64
GOHOSTOS=windows
GOOS=linux

What did you do?

https://gist.github.com/TKSS3/dde5491ba0d96ae8bff0b816dd4d9fbc

What did you expect to see?

Since the windows registry part is not being used if GOOS=Linux, I expected to see no errors and succesfull build

What did you see instead?

.\test.go:24:17: undefined: registry.OpenKey
.\test.go:24:34: undefined: registry.CURRENT_USER
.\test.go:24:82: undefined: registry.QUERY_VALUE
@kardianos
Copy link
Contributor

You need to lookup build tags. https://golang.org/pkg/go/build/

Name one file task.go, then put linux specific calls into task_linux.go and task_windows.go and it will choose the correct files to compile be convention, even without build tags.

@bradfitz
Copy link
Contributor

Yeah, what @kardianos said.

@TKSS3
Copy link
Author

TKSS3 commented Mar 19, 2019

Thank you for your help! I will look into it.

@golang golang locked and limited conversation to collaborators Mar 18, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

4 participants