Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
Try Web Assembly for Go!! ~ gopherdojo#3 LT ~
Search
Sponsored
·
SiteGround - Reliable hosting with speed, security, and support you can count on.
→
Go Takagi
September 18, 2018
Technology
2.4k
0
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
Try Web Assembly for Go!! ~ gopherdojo#3 LT ~
https://mercari.connpass.com/event/101178/
Go Takagi
September 18, 2018
More Decks by Go Takagi
See All by Go Takagi
日経電子版のStoreKit2フルリニューアル
shimastripe
4
1.5k
アプリ内課金と自社の認証認可基盤を連携する複雑な課金ネットワークを構築する
shimastripe
5
4.6k
日経iOSプロジェクトのマルチモジュール戦略
shimastripe
45
2.1k
UIKit ベースの Custom UIContentConfiguration API を 用いた複雑なカスタムセルの作り方
shimastripe
14
4k
リーダーアプリに外部課金リンクを設置する
shimastripe
2
2k
Effective PencilKit / 新聞スクラップ体験の実現
shimastripe
4
3.9k
SPM Build tools を用いて SwiftGen を導入する上での罠とTips / SPM-SwiftGen-Plugin
shimastripe
6
3.4k
Background Notificationで新聞紙面の大きい画像の自動ダウンロードを実現する
shimastripe
12
5.6k
Otemachi.swift#04 今から始めるCodable移行
shimastripe
1
1.2k
Other Decks in Technology
See All in Technology
From Prompt Engineering to Loop Engineering
shibuiwilliam
1
320
認証認可だけじゃない! ID管理の構成要素と ライフサイクルを意識しよう
ritou
1
440
打造你的 AI 工作流:Agent Skill + MCP 實戰工作坊
appleboy
0
360
MySQL & MySQL HeatWave Report - June 2026
freshdaz
0
270
FinOps X 2026 Recap from Engineer Side #JapanFinOps
chacco38
0
240
デジタル・デザイン:次の50年を描く「進化する青写真」
y150saya
0
770
「ビジネスがわかるエンジニア」とは何か?
ryooob
0
440
知見・人・API・DB・予算 ─ ナイナイ尽くしだった人事データ整備 with dbt、5年間の学び
ken6377
1
130
40代で“やっとエンジニアになれた”――閉じた学びを開き、空の青さを知る / 20260628 Naoki Takahashi
shift_evolve
PRO
4
1.6k
Tech-Verse 2026_Keynote
lycorptech_jp
PRO
0
120
作る力から、見極める力へ — AI時代に広がるエンジニアの価値と役割
rince
0
390
#エンジニアBooks 30分でわかる 「技術記事を書く技術」 / engineer-books 2026-06-30
jnchito
1
170
Featured
See All Featured
How to Think Like a Performance Engineer
csswizardry
28
2.7k
A designer walks into a library…
pauljervisheath
211
24k
Unsuck your backbone
ammeep
672
58k
Breaking role norms: Why Content Design is so much more than writing copy - Taylor Woolridge
uxyall
0
340
How to train your dragon (web standard)
notwaldorf
97
6.7k
Jamie Indigo - Trashchat’s Guide to Black Boxes: Technical SEO Tactics for LLMs
techseoconnect
PRO
0
240
DevOps and Value Stream Thinking: Enabling flow, efficiency and business value
helenjbeal
1
250
Designing Powerful Visuals for Engaging Learning
tmiket
1
430
Pawsitive SEO: Lessons from My Dog (and Many Mistakes) on Thriving as a Consultant in the Age of AI
davidcarrasco
0
180
Let's Do A Bunch of Simple Stuff to Make Websites Faster
chriscoyier
508
140k
Rebuilding a faster, lazier Slack
samanthasiow
85
9.5k
What’s in a name? Adding method to the madness
productmarketing
PRO
24
4.1k
Transcript
ϑϩϯτΤϯυͰ Go͍ͨ͠!! Goಓ #3 LTେձ Go Takagi @shimastripe
✦ ໊લ • ߴ ߽ ✦ େֶ • ౦ژۀେֶ M2
✴ ϦόʔεΤϯδχΞϦϯάϓϩάϥϜཧղʹؔ͢ΔݚڀγςϚε ✦ ීஈ • iOS / ϑϩϯτΤϯυपΓ͕جຊ͖Ͱ͢ ✦ SNS • GitHub : @shimastripe • Twitter : @shimastriper • Blog : https://shimastripe.goat.me • KyashID: root ࣗݾհ
Goಓɺ໘ന͔ͬͨ!! ͔ͤͬͩ͘͠࠷৽ͷGoࣄ ৮ͬͯΈ͍ͨ
WebAssembly Go 1.11 adds an experimental port to WebAssembly.
✦ ϑϩϯτ(ϒϥβ)Ͱಈ͘όΠφϦ • ϝΠϯjsͰਏ͔ͬͨύϑΥʔϚϯεΛͳΜͱ͔͢Δ • αΠζখ͍͞ɺಡΈࠐΈվળ ✦ ଟ࠼ͳݴޠ͔ΒੜͰ͖Δ • C/C++/Rust/Go/etc.
✴ WebΛλʔήοτʹίϯύΠϧ͢ΔΠϝʔδ ✴ ࠓ·ͰJavaScriptʹม͢ΔࢼΈ͕ଟ ✤ Scala.jsͱ͔GopherJSͱ͔ Web Assembly
✦ ͋͘·ͰϝΠϯܭࢉߴԽ (ܭࢉ + file size) • ήʔϜͱ͔WebGL ͕͠Β͘ओ ✦
DOMૢ࡞Ͱ͖ͳ͍ (ࠓͷॴ?) • GoͰWebAssembly͔ΒJSͷؔΛίʔϧ (import "syscall/js") • DOM, EventListenerΛҰԠर͑Δ ✦ طଘͷϥΠϒϥϦͱͷ݉Ͷ߹͍ • JSϑϨʔϜϫʔΫ͕ੵΈ্͛ͨࢿ࢈؆୯ʹख์ͤͳ͍ ✦ όΠτίʔυ • ؆қಡԽʹͳΔ͔!! ۜͷؙ͔? (JSΛશͯஔ͖͑Δ???)
✦ Document • Β͍͠doc·ͩͳ͍ • https://github.com/golang/go/wiki/WebAssembly • αϯϓϧίʔυ͕͞ΕͯΔ ✦ ͱΓ͋͑ͣ
$ curl -sO https://raw.githubusercontent.com/golang/go/ master/misc/wasm/wasm_exec.html $ curl -sO https://raw.githubusercontent.com/golang/go/ master/misc/wasm/wasm_exec.js ```main.go func main() { fmt.Println(“Hello WASM!!”) } ```
Hello WASM !! $ GOOS=js GOARCH=wasm go build -o test.wasm
main.go $ open wasm_exec.html Goͷඪ४ग़ྗ͕console.log͞ΕΔ
✦ JS→Gomain͔͠·ͩݺͳ͍? • wasm_exec.js ্Ͱrun(main)͔͠ఆٛ͞Ε͍ͯͳ͍ ✴ JSଆͷ͔͠Εͳ͍ ✦ JS→GoଆʹͤΔ? •
jsͷGo InstanceͷargvʹΛೖΕΔ ✴ os.Args() ͔Βर͑Δ ✴ ڥม͍͚Δ ✦ Go→JSʹͤΔ? • os.Stdoutʹग़ͨ͠Βconsole.log͞ΕΔ͜ͱ͔͠ݟͨΒͳ͍… • Go͔ΒJSΛcallͯ͠eventListenerʹؔΛηοτͰ͖Δ Experimental: ͨͿΜ࠷ॳʹͿͪ͋ͨΔ(ͬͨ)͜ͱ
✦ wasm_exec.js Λ֦ு • console.log ͍ͯͨ͠ՕॴΛDOMʹॻ͖ࠐ·ͤΔ ✦ Goଆ (shimabot.NotifyTrainInformation()) •
ࣗͷChatBotͷ౦ٸઢӡߦεΫϦϓτΛbuild ✴ ఆظతʹݟʹߦͬͯిं͕ࢭ·ͬͯͳ͍͔֬ೝ • JSଆͷnotify()ؔʹొ͢Δ ͏গ͠… writeSync(fd, buf) { outputBuf += decoder.decode(buf); const nl = outputBuf.lastIndexOf("\n"); if (nl != -1) { const elm = document.querySelector("#wrapper"); let div = document.createElement('div'); div.textContent = outputBuf.substr(0, nl); elm.appendChild(div); }
✦ ࣮ߦͰ͖ͨ!! • CORS֎͞ͳ͍ͱ ͍͚ͳ͔ͬͨ • ґଘϥΠϒϥϦͰ Ϗϧυࣦഊ͕݁ߏ͋Γ… ✦ ͬͯΈͯ
• APIϦΫΤετ͘Β͍ͳΒׂͱ ͦͷ··ಈ͔ͤΔ • JSଆ͔ΒGoͷؔΛࢦఆͯ͠ ݺΔΑ͏ʹͳΕศར ϒϥβ্ͰࣗલGoίʔυͷ࣮ߦ
✦ Web Assembly • ϋΠύϑΥʔϚϯε͕ٻΊΒΕΔΑ͏ʹͳͬͨ WebΛࢧ͑ΔͨΊͷόΠφϦΛ༻͍ͨߴԽ ✦ Go Web Assembly
• ·ͩࢼݧ of ࢼݧஈ֊ɻ • GoଆͷؔΛׂͱ؆୯ʹϒϥβͰ࣮ߦͰ͖ͨ • CLIͰ࡞͖ͬͯͨػೳΛ্ख͘׆༻Ͱ͖ͨΓ͠ͳ͍͔? ·ͱΊ ͜Ε͔ΒͷAPI࣍ୈ͚ͩͲɺ͍ΖΜͳ͍ํͰ͖ͦ͏!!
✦ Wiki • https://github.com/golang/go/wiki/WebAssembly ✦ Tutorial • https://www.youtube.com/watch?v=4kBvvk2Bzis • https://www.youtube.com/watch?v=iTrx0BbUXI4
✦ Blog • https://blog.gopheracademy.com/advent-2017/go-wasm/ • https://www.kabuku.co.jp/developers/go-to-webassembly • http://iqeiq.hatenablog.com/entry/2017/12/02/033238 • https://yhara.jp/2017/12/01/webassembly ࢀߟࢿྉ (Ҿ༻)