Warning: Failure to Cross-Compile

353 views
Skip to first unread message

buc...@gmail.com

unread,
Feb 17, 2018, 11:54:22 AM2/17/18
to golang-nuts
Newbie here.  Learning to program in Go...

Just upgraded from 1.8.1 --> the wonderful 1.10; easy to do and smooth (thank you Go Team!!!).  Compiling is faster still!  Question for the congregants:

I write my Go code on a Windows 10 box using VS Code.  Env variable GOOS set to 'freebsd' (my target OS).  For the upgrade, I deleted the c:\Go directory and installed from the 64bit .msi file.  Didn't change anything else.  Perfect, no troubles.

First time I ran VS Code it notified me of the new Go version, said it needed to recompile a bunch of github/fetches and they all FAILED with a warning about not being able to cross-compile...

Is this because I left the GOOS variable set to something other than my development OS?  I tried resetting the GOOS to 'windows' and restarting VS Code, but it looks like I've made my bed, so I went back to GOOS = 'freebsd'.  My project compiles fine.

Is this "failure to cross-compile" the /github/ stuff going to be a problem?  My project only uses the standard libraries.

Ian Lance Taylor

unread,
Feb 17, 2018, 12:25:02 PM2/17/18
to buc...@gmail.com, golang-nuts
What precisely did you try to do, and what precisely happened?

Ian

buc...@gmail.com

unread,
Feb 17, 2018, 12:50:38 PM2/17/18
to golang-nuts

Precisely (as an example, same failure notice):


VS Code with the lukehoban plugin installed.  The plugin gives me this message:

"The Go extension is better with the latest version of "goreturns". Use "go get -u -v sourcegraph.com/sqs/goreturns"

I click "install" and get this:

Installing 1 tool at C:\Users\AKC\Go_Projects\bin
  goreturns


1 tools failed to install.

goreturns:
Error: Command failed: C:\Go\bin\go.exe get -u -v sourcegraph.com/sqs/goreturns
Parsing meta tags from https://sourcegraph.com/sqs/goreturns?go-get=1 (status code 200)
Parsing meta tags from https://golang.org/x/tools/imports?go-get=1 (status code 200)
get "golang.org/x/tools/imports": verifying non-authoritative meta tag
Parsing meta tags from https://golang.org/x/tools?go-get=1 (status code 200)
Parsing meta tags from https://golang.org/x/tools/go/ast/astutil?go-get=1 (status code 200)
get "golang.org/x/tools/go/ast/astutil": verifying non-authoritative meta tag
go get: cannot install cross-compiled binaries when GOBIN is set
Parsing meta tags from https://sourcegraph.com/sqs/goreturns?go-get=1 (status code 200)
Parsing meta tags from https://golang.org/x/tools/imports?go-get=1 (status code 200)
get "golang.org/x/tools/imports": verifying non-authoritative meta tag
Parsing meta tags from https://golang.org/x/tools?go-get=1 (status code 200)
Parsing meta tags from https://golang.org/x/tools/go/ast/astutil?go-get=1 (status code 200)
get "golang.org/x/tools/go/ast/astutil": verifying non-authoritative meta tag
go get: cannot install cross-compiled binaries when GOBIN is set

My GOBIN = C:\Users\AKC\Go_Projects\bin

Ian Lance Taylor

unread,
Feb 17, 2018, 1:50:15 PM2/17/18
to buc...@gmail.com, golang-nuts
Don't set GOBIN. As the error message says, using `go install` with
cross-compiling is not supported when GOBIN is set. The problem is
that it becomes unclear where to install the cross-compiled binary.

Ian



> On Saturday, February 17, 2018 at 10:25:02 AM UTC-7, Ian Lance Taylor wrote:
>>
>>
>>
>> What precisely did you try to do, and what precisely happened?
>>
>> Ian
>
> --
> You received this message because you are subscribed to the Google Groups
> "golang-nuts" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to golang-nuts...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.

buc...@gmail.com

unread,
Feb 17, 2018, 2:09:32 PM2/17/18
to golang-nuts

Okay.  I've deleted the env variable GOBIN.  Next time I'm offered to install goreturn I'll select it and see what happens.

Thank you, Ian!
Reply all
Reply to author
Forward
0 new messages