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.7k
アプリ内課金と自社の認証認可基盤を連携する複雑な課金ネットワークを構築する
shimastripe
5
4.9k
日経iOSプロジェクトのマルチモジュール戦略
shimastripe
45
2.3k
UIKit ベースの Custom UIContentConfiguration API を 用いた複雑なカスタムセルの作り方
shimastripe
14
4.1k
リーダーアプリに外部課金リンクを設置する
shimastripe
2
2k
Effective PencilKit / 新聞スクラップ体験の実現
shimastripe
5
4k
SPM Build tools を用いて SwiftGen を導入する上での罠とTips / SPM-SwiftGen-Plugin
shimastripe
6
3.4k
Background Notificationで新聞紙面の大きい画像の自動ダウンロードを実現する
shimastripe
12
5.7k
Otemachi.swift#04 今から始めるCodable移行
shimastripe
1
1.2k
Other Decks in Technology
See All in Technology
Nav2、Nav3 ... はたまた自作?〜 作って理解する Nav3 の設計意図 〜 / Nav2, Nav3 ... or Build Your Own? — Understanding Nav3's design intent by building it from scratch
yanzm
0
180
少人数データチームのDevin活用実践事例
runandy16
2
420
IDperturb: Enhancing Variation in Synthetic Face Generation via Angular Perturbation
sansantech
PRO
0
110
「重なり」は迎える側がつくる ― 人もAIエージェントも歓迎するプロダクトエンジニアリング ―
go0517go
PRO
0
200
Backstageでつくるセルフサービスな社内開発基盤
kikunosuke75
1
220
AIで開発は速くなったのに、なぜ現場は楽にならないのか 〜あなたの組織のボトルネックを突き止めるワークショップ〜
jacopen
1
230
[DroidKaigi 2026] Making UI specifications visible: Android UI development in the AI agent era supported by Compose Screenshot Testing and galleries
syarihu
0
490
V8コントリビュート超入門
riyaamemiya
0
120
プロダクト思考 × 基盤思考を AIで実現する Compound Engineering
tkc66buzz
1
220
GuardDuty 検知対応を DevOps Agent で効率化しようとしている話 / GuardDuty Investigations with DevOps Agent
masahirokawahara
1
230
Sony-DroidKaigi2026
sony
1
300
AI時代におけるプロダクト横断勉強会の設計
zozotech
PRO
0
130
Featured
See All Featured
RailsConf & Balkan Ruby 2019: The Past, Present, and Future of Rails at GitHub
eileencodes
141
35k
A Tale of Four Properties
chriscoyier
163
24k
Testing 201, or: Great Expectations
jmmastey
46
8.3k
The Invisible Side of Design
smashingmag
301
52k
JavaScript: Past, Present, and Future - NDC Porto 2020
reverentgeek
52
6.1k
The innovator’s Mindset - Leading Through an Era of Exponential Change - McGill University 2025
jdejongh
PRO
1
320
First, design no harm
axbom
PRO
2
1.3k
Build The Right Thing And Hit Your Dates
maggiecrowley
39
3.4k
The Art of Programming - Codeland 2020
erikaheidi
57
14k
How to Build an AI Search Optimization Roadmap - Criteria and Steps to Take #SEOIRL
aleyda
1
2.2k
Stewardship and Sustainability of Urban and Community Forests
pwiseman
0
510
Making Projects Easy
brettharned
120
6.7k
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 ࢀߟࢿྉ (Ҿ༻)