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
3.9k
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
610
マッチングサービスにおける機械学習導入の実際 / Actual implementation of machine learning in matching service
yu81
4
1.8k
人の出会いを支えるPairsとAWSの 切っても切れない関係/inseparable relationship between Pairs and AWS
yu81
1
590
大学を4年で卒業するのはもったいないという話/Do not graduate from-university in 4 years
yu81
0
600
標準ライブラリのコードリーディングで学ぶGo
yu81
0
2.1k
他言語と比較したGo言語の良し悪し及び学習について
yu81
2
28k
Other Decks in Technology
See All in Technology
Namespace, Now and Then
tagomoris
0
170
Azure SQL Database Hyperscale HA レプリカの監視
sansantech
PRO
0
190
waitany と waitall を作った話
mrkn
0
110
20240825_bedrock_helpdesk_jp.pdf
gamogamo
0
130
マーケットプレイス版Oracle WebCenter Content For OCI
oracle4engineer
PRO
1
160
Bidirectional Quadratic Voting Leveraging Issue-Based Matching
kentaro
2
170
ログラスが面白いと思う理由をマネージャーがエモく語ってみる / 20240829 vs LT
yoshikiiida
1
520
(論文読み)LLMからLLMエージェントへ for ソフトウェアエンジニアリング
__ymgc__
1
140
RAGHack: Kickoff and RAG 101
pamelafox
0
190
Our Journey from in-House CD System to Open Source
ffjlabo
0
100
「名前解決」から振り返るAmazon VPC
yuki_ink
0
320
PlaywrightによるE2Eテスト入門 / Introduction to E2E Testing with Playwright
rhumie
3
840
Featured
See All Featured
Faster Mobile Websites
deanohume
304
30k
JavaScript: Past, Present, and Future - NDC Porto 2020
reverentgeek
45
4.8k
Agile that works and the tools we love
rasmusluckow
327
20k
How To Stay Up To Date on Web Technology
chriscoyier
785
250k
実際に使うSQLの書き方 徹底解説 / pgcon21j-tutorial
soudai
165
48k
Designing Dashboards & Data Visualisations in Web Apps
destraynor
226
52k
Thoughts on Productivity
jonyablonski
65
4.2k
"I'm Feeling Lucky" - Building Great Search Experiences for Today's Users (#IAC19)
danielanewman
225
22k
Statistics for Hackers
jakevdp
793
220k
Raft: Consensus for Rubyists
vanstee
135
6.5k
The Straight Up "How To Draw Better" Workshop
denniskardys
230
130k
For a Future-Friendly Web
brad_frost
173
9.3k
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ͰશʹϦϓϨʔε͞Ε͍ͯͯຊʹྑ͔ͬͨɻ