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
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
630
標準ライブラリのコードリーディングで学ぶGo
yu81
0
2.2k
他言語と比較したGo言語の良し悪し及び学習について
yu81
2
28k
Other Decks in Technology
See All in Technology
コンテナセキュリティのためのLandlock入門
nullpo_head
2
330
AWS re:Invent 2024 ふりかえり勉強会
yhana
0
380
あの日俺達が夢見たサーバレスアーキテクチャ/the-serverless-architecture-we-dreamed-of
tomoki10
0
500
オプトインカメラ:UWB測位を応用したオプトイン型のカメラ計測
matthewlujp
0
190
社外コミュニティで学び社内に活かす共に学ぶプロジェクトの実践/backlogworld2024
nishiuma
0
280
AWS環境におけるランサムウェア攻撃対策の設計
nrinetcom
PRO
0
140
成果を出しながら成長する、アウトプット駆動のキャッチアップ術 / Output-driven catch-up techniques to grow while producing results
aiandrox
0
380
レンジャーシステムズ | 会社紹介(採用ピッチ)
rssytems
0
270
5分でわかるDuckDB
chanyou0311
10
3.3k
TSKaigi 2024 の登壇から広がったコミュニティ活動について
tsukuha
0
160
NW-JAWS #14 re:Invent 2024(予選落ち含)で 発表された推しアップデートについて
nagisa53
0
270
watsonx.ai Dojo #5 ファインチューニングとInstructLAB
oniak3ibm
PRO
0
190
Featured
See All Featured
The Straight Up "How To Draw Better" Workshop
denniskardys
232
140k
Code Review Best Practice
trishagee
65
17k
Writing Fast Ruby
sferik
628
61k
How to Think Like a Performance Engineer
csswizardry
22
1.2k
A designer walks into a library…
pauljervisheath
205
24k
JavaScript: Past, Present, and Future - NDC Porto 2020
reverentgeek
47
5.1k
Measuring & Analyzing Core Web Vitals
bluesmoon
4
170
Dealing with People You Can't Stand - Big Design 2015
cassininazir
365
25k
We Have a Design System, Now What?
morganepeng
51
7.3k
The Invisible Side of Design
smashingmag
298
50k
Stop Working from a Prison Cell
hatefulcrawdad
267
20k
How STYLIGHT went responsive
nonsquared
96
5.2k
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ͰશʹϦϓϨʔε͞Ε͍ͯͯຊʹྑ͔ͬͨɻ