Giter VIP home page Giter VIP logo

samplewasm's Introduction

HTTP GET sample in WASM created by Go lang

Go言語のWASM (Web Assembly) で HTTP GET を呼び出すと,以下のようなデッドロックが発生する.

all goroutines are asleep - deadlock!

解決策として,goroutine を使って呼び出せば良いとされている. それで実際にやってみたのがこのリポジトリの内容である.

使い方

  • make を実行すると,serversite/main.wasm が作成される.
  • serverを実行すると,localhost:8080 に HTTP サーバが建てられる(make startを実行しても良い).
    • site 以下のファイルをそのまま返す簡易HTTPサーバ.cmd/server/main.go にソースコードあり.
  • http://localhost:8080 にアクセスし,テキストフィールドに適当なURLを入力し,「Get Content」ボタンを押すと「Content」の下に内容が表示される.

構成

  • Makefile
    • ビルドファイル.
  • httpget.go
    • 単純に HTTP GET しているファイル.
  • src/wasm/main.go
    • wasmから HTTP GET を goroutine で呼び出している.
  • src/server/main.go
    • 簡易 HTTP サーバのプログラム.
  • site/index.html
    • サンプルの html ファイル.
  • site/sample.js
    • site/index.html のアクションを定義し,wasm を呼び出している.
  • site/wasm_exec.js
    • ${GO_INSTALLED_DIR}/misc/wasm/wasm_exec.js からコピーしたもの.

samplewasm's People

Contributors

tamada avatar

Watchers

 avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.