Skip to content

Latest commit

 

History

History
59 lines (38 loc) · 1.25 KB

README.md

File metadata and controls

59 lines (38 loc) · 1.25 KB

Use GopherLua's gopher-lua-libs library to send HTTP(s) requests from inside WASM

Instructions for this devcontainer

Preparation

  1. Open this repo in devcontainer, e.g. using Github Codespaces. Type or copy/paste following commands to devcontainer's terminal.

Building

  1. cd into the folder of this example:
cd browser-gopher-lua-libs
  1. Install GopherLua and the gopher-lua-libs library:
go get github.com/yuin/gopher-lua
go get github.com/vadv/gopher-lua-libs
  1. Workaround compilation error (for WASM target) by updating pq library:
go get -u github.com/lib/pq@master
  1. Compile the example:
GOOS=js GOARCH=wasm go build -o main.wasm main.go
  1. Copy the glue JS from Golang distribution to example's folder:
cp "$(go env GOROOT)/misc/wasm/wasm_exec.js" .

Test with browser

  1. Run simple HTTP server to temporarily publish project to Web:
python3 -m http.server

Codespace will show you "Open in Browser" button. Just click that button or obtain web address from "Forwarded Ports" tab.

  1. As index.html and a 30M-sized main.wasm are loaded into browser, refer to browser developer console to see the results.

Finish

Perform your own experiments if desired.