Skip to content

GopherJS should use GOOS=js instead of build.Default.GOOS #991

@nevkontakte

Description

@nevkontakte

Currently GopherJS specifies GOOS = build.Default.GOOS when it sets up its build context.

This is problematic because when, for example, building on Linux all sources with linux build tag will be picked up unless they explicitly specify !js, which in the standard library mostly isn't the case. This is not great for a two reasons:

  1. We try to build a lot of standard library stuff we probably don't need (e.g. the internal/syscall/unix package). This is very likely leads to unnecessary output bloat.
  2. Output may differ when building on hosts with a different os despite the fact that we are targeting the same execution environment (browser or node).

I think it is better to use GOOS=js at all times to avoid both problems. This will also improve consistency with WebAssembly, which also uses GOOS=js (and GOARCH=wasm).

However, this is a potentially breaking change since people might be expecting GopherJS to pick up linux/windows/whatever code, even though I can't think of a reason why.

@flimzy @neelance @dmitshur any thoughts?

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions