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
620
マッチングサービスにおける機械学習導入の実際 / Actual implementation of machine learning in matching service
yu81
4
1.8k
人の出会いを支えるPairsとAWSの 切っても切れない関係/inseparable relationship between Pairs and AWS
yu81
1
600
大学を4年で卒業するのはもったいないという話/Do not graduate from-university in 4 years
yu81
0
610
標準ライブラリのコードリーディングで学ぶGo
yu81
0
2.1k
他言語と比較したGo言語の良し悪し及び学習について
yu81
2
28k
Other Decks in Technology
See All in Technology
【swonet.conf_】NOCメンバーが語るSTMの実態!! ~ShowNetから若者への贈り物~
shownet
PRO
0
300
【shownet.conf_】ShowNet 2024 ~ Inter * Network ~
shownet
PRO
0
500
【shownet.conf_】コンピューティング資源を統合した分散コンテナ基盤の進化
shownet
PRO
0
390
【shownet.conf_】ShowNet伝送改めShowNet APN 2024
shownet
PRO
0
420
Efficient zero-copy networking using io_uring
ennael
PRO
0
330
I tried the newly introduced certification "Applied Skills" on Microsoft Learn
mappie_kochi
0
130
小さな勉強会の始め方、広げ方、あるいは友達の作り方 / How to Start, Grow, and Build Connections with Small Study Groups
ar_tama
6
2.5k
成果のためのコミュニケーション - 語彙を育てよう -/communication-for-good-outcome-developing-vocabulary
hassaku63
4
160
C# 13 / .NET 9 の新機能 (RC 1 時点)
nenonaninu
1
1.3k
XPを始める新人に伝えたい近道の鍵
nakasho
1
310
【shownet.conf_】3Dアプローチで守るセキュリティ
shownet
PRO
0
370
[JAWS-UG GameTech] 第6回 各種事例紹介_18TRIPにおけるAWSサービスを活用した負荷テスト・障害テスト
naoto_yasuda
0
150
Featured
See All Featured
Docker and Python
trallard
40
3k
Rails Girls Zürich Keynote
gr2m
93
13k
Testing 201, or: Great Expectations
jmmastey
38
7k
A Philosophy of Restraint
colly
202
16k
How to Ace a Technical Interview
jacobian
275
23k
Principles of Awesome APIs and How to Build Them.
keavy
126
17k
The Myth of the Modular Monolith - Day 2 Keynote - Rails World 2024
eileencodes
7
290
BBQ
matthewcrist
85
9.2k
Intergalactic Javascript Robots from Outer Space
tanoku
268
27k
Navigating Team Friction
lara
183
14k
Building Your Own Lightsaber
phodgson
102
6k
[Rails World 2023 - Day 1 Closing Keynote] - The Magic of Rails
eileencodes
29
1.7k
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ͰશʹϦϓϨʔε͞Ε͍ͯͯຊʹྑ͔ͬͨɻ