gopherjs: internal/poll: fails to build on Windows

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

go version go1.9 windows/amd64

What version of GopherJS are you using ?

GopherJS 1.9-1

What did you do?

cat src/hello/main.go

package main

import (
        "github.com/gopherjs/gopherjs/js"
        "fmt"
)

func SayHello(name string) string {
	fmt.Println("Hello", name)
        return "Hello " + name
}

func main() {
        js.Module.Get("exports").Set("SayHello", SayHello)
}

gopherjs build hello/main.go

What did you expect to see?

No errors

What did you see instead?

..\..\..\..\..\..\Go\src\internal\poll\fd_windows.go:367:22: invalid operation: fd.pd (variable of type pollDesc) has no field or method runtimeCtx
..\..\..\..\..\..\Go\src\internal\poll\fd_windows.go:368:22: invalid operation: fd.pd (variable of type pollDesc) has no field or method runtimeCtx
..\..\..\..\..\..\Go\src\internal\poll\fd_windows.go:157:5: invalid operation: o.fd.pd (variable of type pollDesc) has no field or method runtimeCtx

I think the bug is caused by commit 956dce4

About this issue

  • Original URL
  • State: open
  • Created 7 years ago
  • Reactions: 2
  • Comments: 20 (10 by maintainers)

Commits related to this issue

Most upvoted comments

Your suggestion will work

Good to hear.

but let’s recognize that it is a work-around.

It certainly is. That’s why this issue is open and has bug, NeedsFix labels.

It would be nice to fix the two underlying issues so that environments can be consistent across go and gopherjs.

It will be nice to fix this issue, but, that doesn’t mean the environments can be consistent. GOOS and GOARCH environment variables are effectively arguments to the Go compiler. The GopherJS compiler also uses the GOOS environment variable in the same way. You can read more about it at https://golang.org/doc/install/source#environment.

So, you’re expected to set GOOS or GOARCH as needed depending on what target you want to compile for (i.e., cross-compilation). Also see https://medium.com/@rakyll/go-1-5-cross-compilation-488092ba44ec for more information on cross-compilation.

I will work on fixing the bug soon.

Okay, I investigated this and posted #693. My original plan to resolve this issue was to make gopherjs always build for the same supported GOOS value. That way, I could fix Windows without actually having to use it.

Unfortunately, that proposal won’t work exactly as I imagined it (a 2 line PR), and fixing Windows support is going to be more work.

I can’t afford to spend time on supporting Windows now, so I won’t be actively working on this.

You can either continue to use GOOS=darwin gopherjs build, etc., for building JavaScript for running in the browser, or use a supported OS (perhaps in a VM). Or maybe someone else will want to work on fixing Windows. Sorry about the inconvenience.

fails for me too on win10 too btw.

I can reproduce locally on macOS:

$ GOOS=windows gopherjs run main.go 
../../../../../../../../../../../usr/local/go/src/internal/poll/fd_windows.go:367:22: invalid operation: fd.pd (variable of type pollDesc) has no field or method runtimeCtx
../../../../../../../../../../../usr/local/go/src/internal/poll/fd_windows.go:368:22: invalid operation: fd.pd (variable of type pollDesc) has no field or method runtimeCtx
../../../../../../../../../../../usr/local/go/src/internal/poll/fd_windows.go:157:5: invalid operation: o.fd.pd (variable of type pollDesc) has no field or method runtimeCtx