Skip to content

Instantly share code, notes, and snippets.

@fahadsiddiqui
Created November 15, 2024 08:10
Show Gist options
  • Save fahadsiddiqui/7eb68dbb1b19fa77b98000eacf2be1fc to your computer and use it in GitHub Desktop.
Save fahadsiddiqui/7eb68dbb1b19fa77b98000eacf2be1fc to your computer and use it in GitHub Desktop.
imports syscall/js: build constraints exclude all Go files in /usr/local/go/src/syscall

The syscall/js package has a build constraint.

Solution

Put this on top of the main file before package / wherever the syscall/js is imported

//go:build js && wasm

And then build using

GOOS=js GOARCH=wasm go build -o main.wasm
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment