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
僕がGoを選ぶ理由
Search
Koki Natsume
September 23, 2018
Programming
0
1.1k
僕がGoを選ぶ理由
Student Go #1 ビギナーズセッション 2 の発表資料です。
僕のGoの好きなところをまとめました。
Koki Natsume
September 23, 2018
Tweet
Share
More Decks by Koki Natsume
See All by Koki Natsume
5分で入門するFlutter
natumn
0
1.4k
New Business Card
natumn
0
1.1k
Other Decks in Programming
See All in Programming
MCPで実現するAIエージェント駆動のNext.jsアプリデバッグ手法
nyatinte
7
900
Terraform やるなら公式スタイルガイドを読もう 〜重要項目 10選〜
hiyanger
13
3.2k
コーディングは技術者(エンジニア)の嗜みでして / Learning the System Development Mindset from Rock Lady
mackey0225
2
580
250830 IaCの選定~AWS SAMのLambdaをECSに乗り換えたときの備忘録~
east_takumi
0
240
Microsoft Orleans, Daprのアクターモデルを使い効率的に開発、デプロイを行うためのSekibanの試行錯誤 / Sekiban: Exploring Efficient Development and Deployment with Microsoft Orleans and Dapr Actor Models
tomohisa
0
210
WebAssemblyインタプリタを書く ~Component Modelを添えて~
ruccho
1
920
「リーダーは意思決定する人」って本当?~ 学びを現場で活かす、リーダー4ヶ月目の試行錯誤 ~
marina1017
0
240
Claude Codeで実装以外の開発フロー、どこまで自動化できるか?失敗と成功
ndadayo
2
1.5k
AI OCR API on Lambdaを Datadogで可視化してみた
nealle
0
180
コンテキストエンジニアリング Cursor編
kinopeee
1
710
Understanding Ruby Grammar Through Conflicts
yui_knk
1
140
AIでLINEスタンプを作ってみた
eycjur
1
200
Featured
See All Featured
Art, The Web, and Tiny UX
lynnandtonic
302
21k
Put a Button on it: Removing Barriers to Going Fast.
kastner
60
4k
Why You Should Never Use an ORM
jnunemaker
PRO
59
9.5k
Automating Front-end Workflow
addyosmani
1370
200k
The Illustrated Children's Guide to Kubernetes
chrisshort
48
50k
Designing Dashboards & Data Visualisations in Web Apps
destraynor
231
53k
Become a Pro
speakerdeck
PRO
29
5.5k
Visualizing Your Data: Incorporating Mongo into Loggly Infrastructure
mongodb
48
9.6k
Navigating Team Friction
lara
189
15k
Balancing Empowerment & Direction
lara
2
590
A Tale of Four Properties
chriscoyier
160
23k
Building Applications with DynamoDB
mza
96
6.6k
Transcript
͕ ɹɹ ΛબͿཧ༝ 4UVEFOU(P ϏΪφʔηογϣϯ
ࣗݾհ ϋϯυϧωʔϜ: natumn/natumndb ֶߍ: ձେֶ ֶ෦3ੜ GoͰ͍ͬͯΔ͜ͱ: • GAE/Go ʹΑΔαʔόʔαΠυͷ։ൃ
(ΞϧόΠτ) • CLI, slack botͳͲπʔϧ܈ͷ։ൃ (झຯ) • ֶ͚ݕࡧΤϯδϯweb-int-searcherͷ։ൃ (େֶͰͷ׆ಈ) • etc…
StudentGoͷϞνϕʔγϣϯ
ͬͱGoΛ͖ʹʂ
ࠓ͢͜ͱ
ॳ৺ऀͳ͕GoֶΜͰ͍͘աఔͰ͖ͳͬͨͱ͜Ζ
࣍ •ͳͥGoͭ͘ΒΕͨͷ͔ •͍ͭGoͰ͔͘ͷ͔ •GoΛֶͿ •ੜ࢈ੑΛ͋͛ΔͨΊʹ •·ͱΊ
ͳͥ(Pͭ͘ΒΕͨͷ͔ ͳͥGoogle Go Λ͔ͭͬͨ͘
Go at Google: Language Design in the Service of Software
Engineering ͳͥ(Pͭ͘ΒΕͨͷ͔
URL: https://talks.golang.org/2012/splash.article ͳͥ(Pͭ͘ΒΕͨͷ͔
github.com/golang/go/wiki ͳͥ(Pͭ͘ΒΕͨͷ͔
golang.org/doc FAQ ͳͥ(Pͭ͘ΒΕͨͷ͔
GoogleͰେنͳιϑτΣΞΛ ։ൃ͢Δࡍʹൃੜͨ͠ʹର͢Δͻͱͭͷղܾࡦ ͳͥ(Pͭ͘ΒΕͨͷ͔
• ϚϧνίΞϓϩηοαͷීวԽʹ͏ϓϩάϥϛϯάݴޠ ͷαϙʔτ͕গͳ͍ • WebϓϩάϥϛϯάϞσϧʹ͋ͬͨݴޠ͕ͳ͍ʁ • ઍສߦͷίʔυ • ඦɺઍͷ։ൃऀɺ·ͨͦͷ։ൃڥ •
େنͳίʔυʹΑΔϏϧυ࣌ؒͷ૿Ճ Google๊͕͑ͨ ͳͥ(Pͭ͘ΒΕͨͷ͔
• खଓ͖ܕͱඇಉظϓϩάϥϛϯά, LLݴޠͷΑ͏ͳ؆୯͞, ੩తܕ͚Λ ߹ΘͤͨσβΠϯ • ։ൃऀͷબࢶΛڱΊΔγϯϓϧͳจ๏, ॻ͖ํͷ౷Ұ • ϥΠϒϥϦɺϑΥʔϚολ,
Ϧϯλ, ࣗಈੜͳͲπʔϧͷඪ४αϙʔτ Ͱॆ࣮ͤ͞Δ • γϯάϧόΠφϦ ͦͷղܾࡦͱͯ͠ͷGo ͳͥ(Pͭ͘ΒΕͨͷ͔
• खଓ͖ܕͱඇಉظϓϩάϥϛϯά, LLݴޠͷΑ͏ͳ؆୯͞, ੩తܕ͚Λ ߹ΘͤͨσβΠϯ • ։ൃऀͷબࢶΛڱΊΔγϯϓϧͳจ๏, ॻ͖ํͷ౷Ұ • ϥΠϒϥϦɺϑΥʔϚολ,
Ϧϯλ, ࣗಈੜͳͲπʔϧͷඪ४αϙʔτ Ͱॆ࣮ͤ͞Δ • γϯάϧόΠφϦ ͦͷղܾࡦͱͯ͠ͷGo ͳͥ(Pͭ͘ΒΕͨͷ͔ γεςϜͷεέʔϥϏϦςΟ ։ൃͷεέʔϥϏϦςΟ
• GoϓϩάϥϜGorutineͱݴΘΕΔܰྔεϨουͰಈ͘ • GoͷϥϯλΠϜOSεϨου্ʹͦΕͧΕGroutineΛׂ Γͯͯεέδϡʔϧ͢Δ खଓ͖ͱඇಉظϓϩάϥϛϯάΛ߹ΘͤͨσβΠϯ ͳͥ(Pͭ͘ΒΕͨͷ͔ . ( 1
( ( running! waiting… ࢀߟਤ: GopherCon 2017: Kavya Joshi - Understanding Channels
• ྫ͑ɺϊϯϒϩοΩϯάIOͳͲͷͪঢ়ଶ͕ൃੜ͢Δͱ ผͳGroutine͕ಈ͖ग़͢ खଓ͖ͱඇಉظϓϩάϥϛϯάΛ߹ΘͤͨσβΠϯ ͳͥ(Pͭ͘ΒΕͨͷ͔ . ( 1 ( (
running! waiting… ࢀߟਤ: GopherCon 2017: Kavya Joshi - Understanding Channels
• ྫ͑ɺϊϯϒϩοΩϯάIOͳͲͷͪঢ়ଶ͕ൃੜ͢Δͱ ผͳGroutine͕ಈ͖ग़͢ खଓ͖ͱඇಉظϓϩάϥϛϯάΛ߹ΘͤͨσβΠϯ ͳͥ(Pͭ͘ΒΕͨͷ͔ . ( 1 ( (
running! waiting… ࢀߟਤ: GopherCon 2017: Kavya Joshi - Understanding Channels جຊతʹ։ൃऀ͕ͦ͜Λ ҙࣝ͠ͳͯ͘ Runtime͕উखʹඇಉظ ϓϩάϥϛϯάͯ͘͠ΕΔ!!!
• mapfilterͳ͠ͷforจʹΑΔ෮ॲཧ • ྫ֎ػߏͳ͠ͷ໌ࣔతͳΤϥʔϋϯυϦϯά • goͱ͔͚ͩ͘ฒྻॲཧ͕Մೳ • interfaceʹΑΔநԽ, ίϯϙδοτͷ࣮ݱ •
։ൃऀ͕ϝϞϦཧͤͣʹ͢ΉGC͕͋Δ γϯϓϧͳจ๏ ͳͥ(Pͭ͘ΒΕͨͷ͔
• mapfilterͳ͠ͷforจʹΑΔ෮ॲཧ • ྫ֎ػߏͳ͠ͷ໌ࣔతͳΤϥʔϋϯυϦϯά • goͱ͔͚ͩ͘ฒྻॲཧ͕Մೳ • interfaceʹΑΔநԽ, ίϯϙδοτͷ࣮ݱ •
։ൃऀ͕ϝϞϦཧͤͣʹ͢ΉGC͕͋Δ γϯϓϧͳจ๏ ͳͥ(Pͭ͘ΒΕͨͷ͔ ։ൃऀ͕ॻ͚Δදݱ͕େମܾ·ͬͯ͘Δ
γεςϜͷεέʔϥϏϦΟ ͳͥ(Pͭ͘ΒΕͨͷ͔ Goͷඪ
ݱ࣮తͳΛղܾ͢ΔͨΊͷ߹ཧతͳݴޠ ͕͖ͦ͜͜ͷ̍ ͳͥ(Pͭ͘ΒΕͨͷ͔
ͨͪͲΜͳ࣌ʹඞཁ͔
͍ͭ(PͰॻ͘ͷ͔ ظʹΘͨͬͯෳਓͷ։ൃऀͰ։ൃɺӡ༻͍ͯͨ͘͠Ίͷ େنͳϓϩμΫτ, ༷ʑͳਓ͕৮ΔOSSͱͯ͠ • γϯάϧόΠφϦ • γϯϓϧͳจ๏
͍ͭ(PͰॻ͘ͷ͔ ඇಉظϓϩάϥϛϯάͱͯ͠ • ΞϓϦέʔγϣϯαʔόʔͷϓϩάϥϛϯά • IOͷଟ͍ϓϩάϥϜ
͕͖ͦ͜͜ͷ2 ͍ͭ(PͰॻ͘ͷ͔ ෳਓͰͷ νʔϜ։ൃ, αʔόʔαΠυϓϩάϥϛϯά ͕͍͢͠
͕͖ͦ͜͜ͷ2 ࣗͷ։ൃͱ͏·͍͜ͱϚον͍ͯͨ͠ ͍ͭ(PͰॻ͘ͷ͔ ෳਓͰͷ νʔϜ։ൃ, αʔόʔαΠυϓϩάϥϛϯά ͕͍͢͠
GoΛͲ͏ֶΜͰ͍ͬͨΒ͍͍ʁ
None
None
ͤʹͳΕͨ
ࣗͷྫ
(PΛֶͿ GoΛಡΉձ @ktr_0731, @acomagu, @Yamashou0314 ͱ͍ͬͯΔ झຯͷ͋͏༑ୡɺಉ྅ͱٞ͠ͳ͕ΒΔͱḿͬͨ
(PΛֶͿ GoProverbs,CodeReviewComments ͳͲͷߟ͑ΛͱʹίʔυΛಡΉ
(PΛֶͿ The bigger the interface, the weaker the abstraction. •
ioύοέʔδ Errors are values. Don’t just check errors, handle them gracefully. Don’t panic. • ύοέʔδͷ֤ॴ ྫ
(PΛֶͿ ͍ͬͺ͍ίʔυΛॻ͘
(PΛֶͿ GoGo͔ΒֶΔ ͕͖ͦ͜͜ͷ3
(PΛֶͿ ʮֶͿ্Ͱ͜Μͳ͜ͱΛΔͱ͍͍ʯ ͳͲ͋ͬͨੋඇڭ͑ͯཉ͍͠Ͱ͢ʂ
ޮԽ͍ͨ͠
ඪ४αϙʔτͷπʔϧɺϥΠϒϥϦ܈
ੜ࢈ੑΛ͋͛ΔͨΊʹ goίϚϯυ • Ϗϧυ • ςετ • όΠφϦͷऔಘ • ґଘؔͷཧʢv1.11͔Β)
• ϑΥʔϚολͳͲͷίʔυܗ • ܭଌπʔϧ • ίϯύΠϧ࣌ͷπʔϧ܈
ੜ࢈ੑΛ͋͛ΔͨΊʹ gofmt, linter, vet, lsp • ඪ४ͷίϚϯυͰϑΥʔϚολɺϦϯλʔ͕ೖ͍ͬͯΔ • ։ൃऀͦΕʹै͏͚ͩྑ͍ •
࠷ۙɺLanguage Server ProtocolʹGoඪ४Ͱαϙʔτ!!!
ੜ࢈ੑΛ͋͛ΔͨΊʹ ࣗಈੜ godocίϚϯυ • ίʔυίϝϯτ͔Β υΩϡϝϯτΛࣗಈ ੜ
ੜ࢈ੑΛ͋͛ΔͨΊʹ ࣗಈੜ • go generate • Test: gotests • Mock:
gomock, mockgen command • API: go-swagger, swaggo
ੜ࢈ੑΛ͋͛ΔͨΊʹ go/ast Λͬͨ੩తղੳ • GoͷͨΊͷGo
ੜ࢈ੑΛ͋͛ΔͨΊʹ ࣗͷࣄྫ
ੜ࢈ੑΛ͋͛ΔͨΊʹ [WIP] github.com/natumn/ddog cloud datastoreͷΤϯςΟςΟΠϯσοΫε༻ͷυΩϡϝ ϯτࣗಈੜͯ͘͠ΕΔCLIπʔϧ
։ൃͷεέʔϥϏϦΟ Goͷඪ ੜ࢈ੑΛ͋͛ΔͨΊʹ
ੜ࢈ੑΛ͋͛ΔͨΊʹ ඪ४αϙʔτͰੜ࢈తͳπʔϧ͕ͨ͘͞Μ͋Δ ͕͖ͦ͜͜ͷ4
·ͱΊ • GoGoogleͰى͖ͨݱ࣮తͳΛղܾ͢ΔͨΊʹੜ·Εͨݴ ޠ • ظɺେنͳϓϩμΫτʹదͨ͠ઃܭ • GoGo͔ΒֶΔ • ඪ४αϙʔτͰଟ͘ͷੜ࢈తͳπʔϧɺϥΠϒϥϦ͕ἧ͍ͬͯΔ
Έͳ͞ΜGoͷͲΜͳ͜ͱ͕͖Ͱ͔͢?
͝੩ௌ͋Γ͕ͱ͏͍͟͝·ͨ͠ʂ