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
PHPからGoフルスクラッチの戦後入社組から見た、 Pairsの開発について
Search
yu81
August 18, 2017
Technology
0
4.1k
PHPからGoフルスクラッチの戦後入社組から見た、 Pairsの開発について
2017/08/18 エウレカ x クラスメソッド 夜の合同勉強会 ~Go言語開発の実際のところ~ in 大阪
での発表資料です。
yu81
August 18, 2017
Tweet
Share
More Decks by yu81
See All by yu81
Practical Machine Learning at eureka
yu81
2
650
マッチングサービスにおける機械学習導入の実際 / Actual implementation of machine learning in matching service
yu81
4
1.9k
人の出会いを支えるPairsとAWSの 切っても切れない関係/inseparable relationship between Pairs and AWS
yu81
1
600
大学を4年で卒業するのはもったいないという話/Do not graduate from-university in 4 years
yu81
0
640
標準ライブラリのコードリーディングで学ぶGo
yu81
0
2.2k
他言語と比較したGo言語の良し悪し及び学習について
yu81
2
28k
Other Decks in Technology
See All in Technology
Fearsome File Formats
ange
0
550
アジャイルチームが変化し続けるための組織文化とマネジメント・アプローチ / Agile management that enables ever-changing teams
kakehashi
2
2.5k
Unlearn Product Development - Unleashed Edition
lemiorhan
PRO
2
170
サーバーなしでWordPress運用、できますよ。
sogaoh
PRO
0
170
NOT VALIDな検査制約 / check constraint that is not valid
yahonda
1
110
Alignment and Autonomy in Cybozu - 300人の開発組織でアラインメントと自律性を両立させるアジャイルな組織運営 / RSGT2025
ama_ch
1
1.8k
Unsafe.BitCast のすゝめ。
nenonaninu
0
160
機械学習を「社会実装」するということ 2025年版 / Social Implementation of Machine Learning 2025 Version
moepy_stats
3
170
怖くない!ゼロから始めるPHPソースコードコンパイル入門
colopl
0
240
普通のエンジニアがLaravelコアチームメンバーになるまで
avosalmon
0
670
DevFest 2024 Incheon / Songdo - Compose UI 조합 심화
wisemuji
0
250
TypeScript開発にモジュラーモノリスを持ち込む
sansantech
PRO
3
870
Featured
See All Featured
CSS Pre-Processors: Stylus, Less & Sass
bermonpainter
356
29k
実際に使うSQLの書き方 徹底解説 / pgcon21j-tutorial
soudai
171
50k
Refactoring Trust on Your Teams (GOTO; Chicago 2020)
rmw
33
2.7k
The Myth of the Modular Monolith - Day 2 Keynote - Rails World 2024
eileencodes
19
2.3k
Stop Working from a Prison Cell
hatefulcrawdad
267
20k
The Cult of Friendly URLs
andyhume
78
6.1k
Design and Strategy: How to Deal with People Who Don’t "Get" Design
morganepeng
127
18k
Chrome DevTools: State of the Union 2024 - Debugging React & Beyond
addyosmani
3
230
Evolution of real-time – Irina Nazarova, EuRuKo, 2024
irinanazarova
6
490
RailsConf & Balkan Ruby 2019: The Past, Present, and Future of Rails at GitHub
eileencodes
132
33k
The MySQL Ecosystem @ GitHub 2015
samlambert
250
12k
A Tale of Four Properties
chriscoyier
157
23k
Transcript
Copyright © 2017 eureka, Inc. All rights reserved. PHP͔ΒGoϑϧεΫϥονͷઓޙೖ͔ࣾΒݟͨɺ Pairsͷ։ൃʹ͍ͭͯ
2017/08/18 ΤϨΧ x Ϋϥεϝιου ͷ߹ಉษڧձ ~Goݴޠ։ൃͷ࣮ࡍͷͱ͜Ζ~ in େࡕ ӓҪ ༑྄
Copyright © 2017 eureka, Inc. All rights reserved. ࣗݾհ 2
݄ژେֶཧֶ෦ೖֶ ݄ژେֶେֶӃཧֶݚڀՊཧֶɾӉཧֶઐ߈म࢜՝ఔमྃ ݄גࣜձࣾγεςϜܭըݚڀॴೖࣾ $$ $ ݄ גࣜձࣾ౦ٸϋϯζϋϯζϥϘגࣜձࣾೖࣾ CBTI1)1 ݄גࣜձࣾΤϨΧೖࣾ (P
Copyright © 2017 eureka, Inc. All rights reserved. 3 Pairs
GoϑϧεΫϥονͰߦͬͨ͜ͱ - PHP(CodeIgniter2)͔ΒGoͷΞϓϦέʔγϣϯίʔυͷஔ͖͑ - WAFॳ࠾༻ͨ͠Revel͔Βឯ༨ۂં͋ΓGinɻ - DBεΩʔϚͷݟ͠ͱશσʔλͷϚΠάϨʔγϣϯ - MySQL - DynamoDB - ύʔςΟγϣχϯάͷڪා - 2ͭͷϦϓϨʔεΛಉ࣌ʹ(Β͍͠)ɻ
Copyright © 2017 eureka, Inc. All rights reserved. 4 Pairs
αʔόαΠυٕज़ελοΫ - Go(1.7) - Gin(WAF) - Circus(daemonize) - xorm(ORM) - logrus(log) - glide(vendoring) - MySQL on EC2 - Amazon Aurora - Amazon DynamoDB - Redis on Amazon ElastiCache - Google BigQuery(BI) - Sentry(error log tracking) - SemaphoreCI(CI) - etc…
͜ͷ1Ͱͷݟʹ͍ͭͯɺ֤తʹɻ
Copyright © 2017 eureka, Inc. All rights reserved. 6 چίʔυ(PHP)ͱͷൺֱ
- ίʔυϕʔεґવͱͯ͠େ͖͍ͷͷ(ेສߦ)ɺಡΊΔɻ - PHP൛ͷUser Model ͔ͬͨɻಡΊͳ͍ɻ - ͨΓલ͕ͩɺڧ͍੩తܕ͚ʹΑΔ҆৺ײɻ - IntelliJ(Gogland)ʹΑΔαϙʔτ͋Δɻ - ͕ͩࣾʹVimmer͕ଟ͍ɻ - લ৬ͰPHPΛॻ͍͍͕ͯͨɺPHP൛ͷίʔυΛݟͯ͜ΕʹߩݙͰ͖ ͳ͍ؾ͕͢Δ……ͱࢥͬͨɻ - ະܦݧͷGoͷίʔυͷํ͕·ͩಡΊΔؾ͕ͨ͠ɻ
Copyright © 2017 eureka, Inc. All rights reserved. 7 ϒϥϯνઓུ
- GitHub-Flow Λ࠾༻ - master ͕͍ͭͰσϓϩΠՄೳͳঢ়ଶΛอͭ - Goʹशख़ͨ͠ਓ͕ଟ͘ͳ͔ͬͨɾٕྔ͕ࠩେ͖͔ͬͨ࣌ɺख़ୡऀͷ LGTM͕ग़Δ·ͰϚʔδෆՄͱ͍ͯͨ͠ɻ - શମతͳϨϕϧΞοϓʹΑΓఫഇɻ - ઃܭ͔Βࡉ͔͍Goͷ༷෦(εϥΠεͷѻ͍ͱ͔)·Ͱ͕ͬͪΓݟ͍ͯ ͕ͨɺͩΜͩΜͱෆཁʹͳ͍ͬͯͬͨ
Copyright © 2017 eureka, Inc. All rights reserved. 8 Pairs
ϝΠϯϦϙδτϦͷύοέʔδ֓ཁ - libs - αʔϏεͷϩδοΫΞϓϦέʔγϣϯͱແؔ࿈ɾؔ࿈ͷബ͍ͷ - core - config, i18n, log ͳͲɻ - pairscore - ෳserviceڞ௨ͷϏδωεϩδοΫDBؔ࿈(entity, repository)ɻ - image,aws/{s3,sns,sqs} ͳͲ - service/pairsmain - ΞϓϦέʔγϣϯݻ༗ͷϩδοΫ - service/pairsadmin - ཧը໘ - service/pairsbatch - όον
Copyright © 2017 eureka, Inc. All rights reserved. 9 Pairs
ϝΠϯϦϙδτϦͷύοέʔδ֓ཁ - લड़ͷύοέʔδߏϕετͳͷ͔ʁ - ͱΘΕΕɺվળͷ༨͕͋Δߏɻ - Ͳ͏Έͯpairscore͕ɺྔతʹ֊తʹfatʹͳΓ͕ͪɻ - ࣾͷଞϚΠΫϩαʔϏεͰɺDDDʹଇͬͨͷͳͲ͕͋Δɻ
Copyright © 2017 eureka, Inc. All rights reserved. 10 ύοέʔδߏͷࢦ
- ࠔͬͨΒެࣜɾඪ४ϥΠϒϥϦʹ͏ - Our CTO says too… - https://speakerdeck.com/kaneshin/go-package-guidelines
Copyright © 2017 eureka, Inc. All rights reserved. 11 ϑϨʔϜϫʔΫ͕GinͰ͋Δཧ༝
- ·ͣௐࠪͷ݁ՌRevelΛ࠾༻ͯ͠Έͨͱ͜Ζɺগͳ͘ͱ࣌ͷRevel͕͍ ʹ͔ͬͨ͘ͱ͍͏ͷ͕͋Δ༷(͜ͷ͋ͨΓฉ) - RevelϑϧελοΫͳϑϨʔϜϫʔΫͰɺٻΊ͍ͯͨػೳʹରͯ͠ඞཁҎ্ ʹڊେͰଟػೳͰ͋ͬͨͨΊɺ໘ͰϚΠΫϩϑϨʔϜϫʔΫʹ܉͕ ্͕Δɻ - ࣌ͷબఆͰGin͕બΕͨͱ͍͏͚ͩɻ - Revel to Gin ͷϦϓϨʔε1ϲ݄ͰߦΘΕͨΒ͍͠…… - ࠷ۙঃʑʹࣾαʔϏε͕ϚΠΫϩαʔϏεԽ͞Ε͍ͯΔ͕ɺͦͷࡍgoji͕ Α͘࠾༻͞Ε͍ͯΔɻ
Copyright © 2017 eureka, Inc. All rights reserved. 12 Goʹ͓͚ΔϑϨʔϜϫʔΫબఆ
- ͦͦɺϑϨʔϜϫʔΫ͍Βͳ͍ͷͰ͕ࣾͷҰ෦Ͱʹɻ - ࠷ݶͷϛυϧΣΞ͕͋ΕेͰ…… - github.com/urfave/negroni ͕ؾʹͳ͍ͬͯ·͢ɻ
Copyright © 2017 eureka, Inc. All rights reserved. 13 vendoringͲ͏͋Δ͖͔(ߟ͑ํ)
- ͳΜͰ͔ΜͰ֎෦ϥΠϒϥϦΛ͍ͬͯΔͱਏ͘ͳΔ - ΈΜͳ͍͖͍ͩͧ͢Μ͔Μ͚͍͘͡͝ - ෳͷϥΠϒϥϦ͕ผͷϥΠϒϥϦͷޓੑͷແ͍ผʑͷόʔδϣϯʹґଘ ͢Δͱ͔(͋Δ͋Δ) - খ͍͞ϥΠϒϥϦͰ͋Εɺ࣌ʹࣗΒͷϦϙδτϦʹऔΓࠐΜͰར༻͢Δ͜ ͱඞཁʹͳΔɻ - Go·ͩए͘ੵۃతͳΞοϓσʔτ͕ͳ͞Εɺਓޱ૿Ճ͜Ε͔Βͷݴޠͳͷ Ͱɺར༻͢ΔϥΠϒϥϦͷϥΠϑαΠΫϧʹରͯ͠ҙࣝతʹͳΔඞཁ͕͋Δɻ - ʮͦΕɺඪ४ϥΠϒϥϦͰΑ͘ͳ͍ʁʯͱৗʹߟ͑Δɻ
Copyright © 2017 eureka, Inc. All rights reserved. 14 vendoringͲ͏͋Δ͖͔(πʔϧ)
- ެࣜʹΑΔvendoringπʔϧͱͯ͠dep͕ొͨ͠ - ͕ͩɺઃఆϑΝΠϧܗ͕ࣜมߋ͞ΕΔͳͲ͕͔͋ͬͨΓͳͷͰɺ༷ࢠ ݟɻ - ॾʑམͪண͍ͨΒɺ৽͘͠࡞Δ࣌͜Εʹ͢Δͷ͕ਖ਼͘͠ɺ࠷ָʹͳ Γͦ͏ɻ - ݱࡏ༻தͷglide ൺֱత୯७Ͱɺಛʹແ͘ಈ࡞͍ͯ͠Δɻݸਓత ʹ͜ͷ··ͰOKɻ
Copyright © 2017 eureka, Inc. All rights reserved. 15 GoͷόʔδϣϯΞοϓʹ͍ͭͯ
- جຊతʹίϯύΠϧ௨ΔͷͰɺ୯ମςετ͕མͪΔΑ͏ʹͳΒͳ͚Ε େৎɻ - ͕ͩɺͳ͔ͳ͔ϔϏʔͳ͜ͱ͋ͬͨ…… - ۩ମతʹɺGo1.5ҎԼ͔ΒGo1.6Ҏ্ͷΞοϓσʔτ࣌ɻ
Copyright © 2017 eureka, Inc. All rights reserved. 16 GoͷόʔδϣϯΞοϓʹ͍ͭͯ
- https://golang.org/doc/go1.6 - mapͷಉ࣌ॻ͖ࠐΈ͕ൃੜͨ͠߹ɺpanicΛى͜͢Α͏ʹͳͬͨɻ - ී௨ʹߟ͑Εࢸۃ·ͬͱ͏ͳ༷ʹͳͬͨͱ͍͑Δɻ - ར༻͍ͯ͠Δ֎෦ϥΠϒϥϦ(logger, ORM)͕όʔδϣϯ͕ݹ͘ɺ͜Εʹ ରͯ͠unsafeͰɺͦΕΒͷόʔδϣϯΞοϓରԠඞཁʹͳΓͳ͔ͳ͔ ͳ͜ͱʹɻ
Copyright © 2017 eureka, Inc. All rights reserved. 17 GoͷόʔδϣϯΞοϓʹ͍ͭͯ
- ٯʹݴ͏ͱɺࠔͦ͏͍ͬͨͱ͜ΖʹہॴԽ͍ͯͯ͠ɺಓͳ࡞ۀͩͬ ͨɻ - -race ΦϓγϣϯΛ͚ͯڝ߹ঢ়ଶ͕ݕग़Ͱ͖ΔΑ͏ʹ࣮ͯ͠ߦͯ͠ ֘ՕॴΛݟ͚ͭͯ͠…… - ݱࡏ 1.7 ͕ͩɺ͞ΒͳΔόʔδϣϯΞοϓͰಉ༷ͷࠔͳͦ͞͏ɻ - ࣮ผ͕݅ͪΐͬͱ͚ͩ͋Γ·͕͢……(ޱ಄ͷΈͰ)
Copyright © 2017 eureka, Inc. All rights reserved. 18 configʹ͍ͭͯ
- godotenvΛར༻ͯ͠ڥม͔Βऔಘ - ઃఆͷΧςΰϦຖʹߏମΛ४උ͠ɺΞϓϦέʔγϣϯ͔Βͦͷެ։ϝ ϯόΛ௨ͯ͠ར༻ɻ
Copyright © 2017 eureka, Inc. All rights reserved. 19 configʹ͍ͭͯ
Copyright © 2017 eureka, Inc. All rights reserved. 20 ϝϞϦΞϩέʔγϣϯ͍
- ϝϞϦΞϩέʔγϣϯ͕ଟ͍ͱɺ໘Ͱ༗རͳGoεΫϦϓτݴޠฒͷ ʹͳΔέʔεɻ - γεςϜͷϘτϧωοΫͱͳΔཁҼͪΖΜଞʹ͋Δ͕ɺ͕Ұͭ ͷϦͰ͋ΔGoͰ͜ΕΛݪҼͱ͢ΔύϑΥʔϚϯεྼԽͳΔ͘ආ͚ͨ ͍ɻ - ϕϯνϚʔΫΛॻ͘ɺpprofͳͲͷϓϩϑΝΠϦϯάπʔϧΛ͏ͳͲ͠ ͯɺ࠷খԽ͢Δɻ - ςετͱͱʹϕϯνϚʔΫΛॻ͘ͷ͕࠷ָɻ
Copyright © 2017 eureka, Inc. All rights reserved. 21 ਖ਼نදݱ͕(ଟ͘ͷέʔεͰ)͍
- ͜ͷ݅ʹ͍ͭͯ2016ʹϒϩάΛॻ͖·ͨ͠ɻ - https://developers.eure.jp/tech/golang-regexp/ - ΞϧΰϦζϜ͍͍͚Ͳͳ͔͍ͥɻ - ͞Βʹਖ਼نදݱͷίϯύΠϧ͕͍ͨΊɺ͜ͷͨΊʹύοέʔδԼͰ ਖ਼نදݱΦϒδΣΫτΛ֬อ͍ͯ͠ճ͢ͱɺ෦ͷഉଞ੍ޚʹΑΔ ԼʹͿͪͨΔɻ - ެࣜʹ͋ΔΑ͏ʹɺregexp.Copy() ϝιουʹͯར༻ଆ͕ίϐʔͯ͠͏ࣄ Ͱղܾɻ - ϦΞϧλΠϜͰΘΕΔճͱՄಡੑͷόϥϯεΛऔͬͯɺstringsύοέʔδͷ ؔͰସॲཧΛߦ͏ͷ͕ݱ࣮ղɻ
·ͱΊ
Copyright © 2017 eureka, Inc. All rights reserved. 23 ·ͱΊ
- Go૾Ҏ্ʹΩϟονΞοϓ͍͢͠ݴޠͩͬͨ - as C/C++/C#/PHPܦݧऀ - vendoring(ύοέʔδϚωδϝϯτ)ɺΧλ͍πʔϧΛ͍ͭͭɺґଘ͢ΔϥΠϒϥϦͷ ϥΠϑαΠΫϧߟ͑ͯར༻Λߟ͑Δɻ - ඪ४ϥΠϒϥϦͰࡁΉͷͦΕͰࡁ·͢͜ͱΛݕ౼ɻ - ύοέʔδߏʹ͍ͭͯϦϙδτϦͷαΠζʹΑΔ͕ɺඪ४ϥΠϒϥϦΛࢀߟʹ͢Δɻ - ී௨ͷεΫϦϓτݴޠͷϊϦͰॻ͘ͱࢥΘ͵ύϑΥʔϚϯεྼԽʹݟΘΕΔͷͰɺGoͷ ΓํʹଇΔɻ - ͜Εެࣜͷ͍ํΛ·ͣࢀߟʹ͢Δɻ - Pairs͕GoͰશʹϦϓϨʔε͞Ε͍ͯͯຊʹྑ͔ͬͨɻ