Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Sign up for free
Menu
Search
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Pricing
Search
Sign in
Sign up for free
Try Web Assembly for Go!! ~ gopherdojo#3 LT ~
Search
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
アプリログインとWeb認証基盤をつなぐ ASWebAuthenticationSession 作法
shimastripe
1
470
日経電子版のStoreKit2フルリニューアル
shimastripe
4
1.7k
アプリ内課金と自社の認証認可基盤を連携する複雑な課金ネットワークを構築する
shimastripe
5
5.1k
日経iOSプロジェクトのマルチモジュール戦略
shimastripe
45
2.4k
UIKit ベースの Custom UIContentConfiguration API を 用いた複雑なカスタムセルの作り方
shimastripe
14
4.2k
リーダーアプリに外部課金リンクを設置する
shimastripe
2
2.1k
Effective PencilKit / 新聞スクラップ体験の実現
shimastripe
5
4.1k
SPM Build tools を用いて SwiftGen を導入する上での罠とTips / SPM-SwiftGen-Plugin
shimastripe
6
3.5k
Background Notificationで新聞紙面の大きい画像の自動ダウンロードを実現する
shimastripe
12
5.7k
Other Decks in Technology
See All in Technology
AI駆動開発、viviONの1年 ── うまくいったこと・いかなかったこと
vivion
0
210
Futexes the good, the bad, the ugly
ennael
PRO
0
120
スキルを作る、その前に!複数人で使われるスキルを 作るためのプロセス
junkifurukawa
2
260
使いこなすために知っておきたい Azure SRE Agent アンチパターン
torumakabe
2
330
DAMOS - The Smart Cruise Control for RAM
ennael
PRO
1
130
AI 時代の Azure エンジニアリング ~ 私たちは何を磨き、何を任せるのか ~
chack411
1
450
個別開発で終わらせない。 現場の課題をプロダクトの強さに変える StockmarkのFDE
ktkrhr
0
580
自律型 AI をセキュアに実装!Gemini と MIG で作る動的コード実行環境
recruitengineers
PRO
1
210
2026-10-01_MagicPod_QAハーネスエンジニアリングとQA組織の未来像
ynisqa1988
1
520
Snapshot Testing in Practice: Predictable and Reliable SwiftUI Views
fespinoza
0
120
自主式軟體工廠
philipz
0
220
[2026 Oracle Technical Deep Dive] Apache Iceberg × Oracle AI Database -Oracle Autonomous AI Lakehouseが実現するAI時代のデータ基盤- (2026年9月17日開催)
oracle4engineer
PRO
0
110
Featured
See All Featured
Primal Persuasion: How to Engage the Brain for Learning That Lasts
tmiket
0
490
Dealing with People You Can't Stand - Big Design 2015
cassininazir
367
27k
Being A Developer After 40
akosma
91
590k
The MySQL Ecosystem @ GitHub 2015
samlambert
251
13k
Joys of Absence: A Defence of Solitary Play
codingconduct
1
530
Prompt Engineering for Job Search
mfonobong
0
480
End of SEO as We Know It (SMX Advanced Version)
ipullrank
3
4.4k
エンジニアに許された特別な時間の終わり
watany
109
250k
A Soul's Torment
seathinner
8
3.7k
Building Adaptive Systems
keathley
44
3.2k
Test your architecture with Archunit
thirion
2
2.4k
Making Projects Easy
brettharned
120
6.8k
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 ࢀߟࢿྉ (Ҿ༻)