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
4k
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
640
マッチングサービスにおける機械学習導入の実際 / 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
620
標準ライブラリのコードリーディングで学ぶGo
yu81
0
2.2k
他言語と比較したGo言語の良し悪し及び学習について
yu81
2
28k
Other Decks in Technology
See All in Technology
Why App Signing Matters for Your Android Apps - Android Bangkok Conference 2024
akexorcist
0
120
【Pycon mini 東海 2024】Google Colaboratoryで試すVLM
kazuhitotakahashi
2
500
Adopting Jetpack Compose in Your Existing Project - GDG DevFest Bangkok 2024
akexorcist
0
110
オープンソースAIとは何か? --「オープンソースAIの定義 v1.0」詳細解説
shujisado
7
810
Engineer Career Talk
lycorp_recruit_jp
0
160
dev 補講: プロダクトセキュリティ / Product security overview
wa6sn
1
2.3k
誰も全体を知らない ~ ロールの垣根を超えて引き上げる開発生産性 / Boosting Development Productivity Across Roles
kakehashi
1
220
複雑なState管理からの脱却
sansantech
PRO
1
140
iOSチームとAndroidチームでブランチ運用が違ったので整理してます
sansantech
PRO
0
130
開発生産性を上げながらビジネスも30倍成長させてきたチームの姿
kamina_zzz
2
1.7k
ドメインの本質を掴む / Get the essence of the domain
sinsoku
2
150
OCI 運用監視サービス 概要
oracle4engineer
PRO
0
4.8k
Featured
See All Featured
KATA
mclloyd
29
14k
Docker and Python
trallard
40
3.1k
Statistics for Hackers
jakevdp
796
220k
Distributed Sagas: A Protocol for Coordinating Microservices
caitiem20
329
21k
YesSQL, Process and Tooling at Scale
rocio
169
14k
GitHub's CSS Performance
jonrohan
1030
460k
Helping Users Find Their Own Way: Creating Modern Search Experiences
danielanewman
29
2.3k
Save Time (by Creating Custom Rails Generators)
garrettdimon
PRO
27
840
I Don’t Have Time: Getting Over the Fear to Launch Your Podcast
jcasabona
28
2k
Bootstrapping a Software Product
garrettdimon
PRO
305
110k
Fireside Chat
paigeccino
34
3k
CoffeeScript is Beautiful & I Never Want to Write Plain JavaScript Again
sstephenson
159
15k
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ͰશʹϦϓϨʔε͞Ε͍ͯͯຊʹྑ͔ͬͨɻ