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
How to write CUI application in Go
Search
Takashi Kokubun
June 17, 2014
Programming
4
3k
How to write CUI application in Go
Takashi Kokubun
June 17, 2014
Tweet
Share
More Decks by Takashi Kokubun
See All by Takashi Kokubun
YJIT Makes Rails 1.7x faster / RubyKaigi 2024
k0kubun
7
13k
Ruby JIT Hacking Guide / RubyKaigi 2023
k0kubun
2
9.5k
YJIT: Dive into Ruby's JIT compiler written in Rust / Rust.Tokyo 2022
k0kubun
1
2k
Towards Ruby 4 JIT / RubyKaigi 2022
k0kubun
3
11k
Optimizing Production Performance with MRI JIT / RubyConf 2021
k0kubun
1
410
Why Ruby's JIT was slow / RubyKaigi Takeout 2021
k0kubun
3
1.8k
数時間かかる週一リリースを毎日何度も爆速でできるようにするまで / CI/CD Conference 2021
k0kubun
21
14k
Ruby 3 JIT's roadmap / RubyConf China 2020
k0kubun
0
770
Ruby 3.0 JIT on Rails
k0kubun
9
9.1k
Other Decks in Programming
See All in Programming
MCP with Cloudflare Workers
yusukebe
2
220
PHPで作るWebSocketサーバー ~リアクティブなアプリケーションを知るために~ / WebSocket Server in PHP - To know reactive applications
seike460
PRO
2
470
「とりあえず動く」コードはよい、「読みやすい」コードはもっとよい / Code that 'just works' is good, but code that is 'readable' is even better.
mkmk884
3
470
ある日突然あなたが管理しているサーバーにDDoSが来たらどうなるでしょう?知ってるようで何も知らなかったDDoS攻撃と対策 #phpcon.2024
akase244
0
130
CQRS+ES の力を使って効果を感じる / Feel the effects of using the power of CQRS+ES
seike460
PRO
0
140
PSR-15 はあなたのための ものではない? - phpcon2024
myamagishi
0
130
Zoneless Testing
rainerhahnekamp
0
120
ゆるやかにgolangci-lintのルールを強くする / Kyoto.go #56
utgwkk
2
390
テストコード文化を0から作り、変化し続けた組織
kazatohiei
2
1.5k
アクターシステムに頼らずEvent Sourcingする方法について
j5ik2o
4
290
Haze - Real time background blurring
chrisbanes
1
510
たのしいparse.y
ydah
3
120
Featured
See All Featured
Why Our Code Smells
bkeepers
PRO
335
57k
The Cult of Friendly URLs
andyhume
78
6.1k
How STYLIGHT went responsive
nonsquared
95
5.2k
Into the Great Unknown - MozCon
thekraken
33
1.5k
Side Projects
sachag
452
42k
A Philosophy of Restraint
colly
203
16k
Imperfection Machines: The Place of Print at Facebook
scottboms
266
13k
We Have a Design System, Now What?
morganepeng
51
7.3k
Build your cross-platform service in a week with App Engine
jlugia
229
18k
The Web Performance Landscape in 2024 [PerfNow 2024]
tammyeverts
2
290
Scaling GitHub
holman
458
140k
Building an army of robots
kneath
302
44k
Transcript
2014/06/17 hikarie.go How to write CUI application in Go by
@k0kubun
ɾRails app engineer ɾGithub, Twitter: ɹ@k0kubun Έͳ͞ΜɺॳΊ·ͯ͠ Takashi Kokubun
ಥવͰ͕͢
օ͞ΜීஈGoͰ ԿΛॻ͍͍ͯ·͔͢ʁ
ࢲɺ
scheme interpreter
Twitter client
peco (just contribution)
TETRIS
CUI
Why do I write CUI application in Go?
Because
I work with Terminal, !
I work with Terminal, I love Terminal,
I work with Terminal, I love Terminal, I live in
Terminal.
And
Go is Fast
I love to use fast CUI app
That's all.
ࢲͷߟ͑
ͱΓ͋͑ͣGoͰ ॻ͍ͱ͚ͦ͏ ࢲͷߟ͑
Α͠ॻ͍ͯΈΑ͏
None
ΧʔιϧҠಈͰ͖Δ Α͏ʹ͍ͨ͠
r := bufio.NewReader(os.Stdin) buf, _ := r.ReadString('\n') ...
ɾɾɾʁ
EnterΩʔԡ͢·Ͱ Ωʔೖྗड͚औΕͳ͍
ࠔͬͨ
ΊͬͪΌάάͬͨ ΊͬͪΌίʔυړͬͨ
݁Ռ
mattn/http-gonsole uses go-readline
ɾgo-readline ɹɾGNU readlineґଘ(໘), GPL ɹɾUTF-8ରԠͯ͠Δ, WindowsՄ ɾgo.linenoise ɹɾ1100ߦͷCͷίʔυ, BSD ɹɾUTF-8ରԠͯ͠ͳ͍…,
Windowsແཧ readlineܥͷϥΠϒϥϦ͍·͠ΐ͏ ͳΜ͔Ϗϧυࣦഊͨ͠Γ͢ΔͷͰదͳϑΥʔΫ୳͔ࣗ͢Ͱ͢
ͬͱॻ͍ͯΈΑ͏
None
Ͳ͏͢Μͩ͜Ε ผʹจࣈΛೖྗ͍ͨ͠Θ͚͡Όͳ͍
linenoiseͷίʔυಡΜͰΈΔ͔ ͕ͬͯΔͭ ͨͬͨͷ1100ߦʂ
linenoiseͷίʔυಡΜͰΈΔ͔ ͜Μͳͷʹ 3ສߦॻ͘ඞཁ͕ ͋Δͷ͔ʁ ͔͍͍ͬ͜
݁Ռ
#include <termios.h> tcsetattr()
termiosͷcgoόΠϯσΟϯάॻ͍ͨ k0kubun/go-termios ॻ͍͔ͯΒؾ͍͚ͮͨͲdavecheneyͷ github.com/pkg/term ྑ͛͞
ͰϙʔλϏϦςΟ͍ Windows? ͪΐͬͱฉ͍ͨ ͜ͱͳ͍Ͱ͢Ͷ
·ͨίʔυړͬͨ
lestrrat/peco uses termbox-go
ɾWindowsରԠͯ͠ΔͬΆ͍ ɾେମͷΩʔೖྗఆͰ͖Δ ɾ࠲ඪࢦఆ͍ͯ͠Ζ͍Ζॻ͚Δ termbox-goྑ͍Ͱ͢
termbox-go ศར
·ͱΊ
ɾCUIΞϓϦॻ͜͏ ɾtermbox-goศར ·ͱΊ
Thank you for your listening