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
Go CLI Hands-on
Search
taxio
June 22, 2019
Programming
0
660
Go CLI Hands-on
taxio
June 22, 2019
Tweet
Share
More Decks by taxio
See All by taxio
go gc algorithm 101
taxio
12
9k
go-gc-1
taxio
1
310
ISUCON出ようぜ!
taxio
0
66
Shutdown workers
taxio
0
220
catchup.pdf
taxio
0
55
Layered Architecture
taxio
0
93
SummerReport
taxio
0
68
ReactTutorial
taxio
0
71
ボスキタスイッチ.pdf
taxio
0
330
Other Decks in Programming
See All in Programming
とにかくAWS GameDay!AWSは世界の共通言語! / Anyway, AWS GameDay! AWS is the world's lingua franca!
seike460
PRO
1
900
ピラミッド、アイスクリームコーン、SMURF: 自動テストの最適バランスを求めて / Pyramid Ice-Cream-Cone and SMURF
twada
PRO
10
1.3k
ECS Service Connectのこれまでのアップデートと今後のRoadmapを見てみる
tkikuc
2
250
flutterkaigi_2024.pdf
kyoheig3
0
150
광고 소재 심사 과정에 AI를 도입하여 광고 서비스 생산성 향상시키기
kakao
PRO
0
170
3 Effective Rules for Using Signals in Angular
manfredsteyer
PRO
0
120
Contemporary Test Cases
maaretp
0
140
RubyLSPのマルチバイト文字対応
notfounds
0
120
A Journey of Contribution and Collaboration in Open Source
ivargrimstad
0
970
エンジニアとして関わる要件と仕様(公開用)
murabayashi
0
300
EMになってからチームの成果を最大化するために取り組んだこと/ Maximize team performance as EM
nashiusagi
0
100
2024/11/8 関西Kaggler会 2024 #3 / Kaggle Kernel で Gemma 2 × vLLM を動かす。
kohecchi
5
930
Featured
See All Featured
Building Your Own Lightsaber
phodgson
103
6.1k
Fontdeck: Realign not Redesign
paulrobertlloyd
82
5.2k
Statistics for Hackers
jakevdp
796
220k
Imperfection Machines: The Place of Print at Facebook
scottboms
265
13k
Producing Creativity
orderedlist
PRO
341
39k
How to train your dragon (web standard)
notwaldorf
88
5.7k
Responsive Adventures: Dirty Tricks From The Dark Corners of Front-End
smashingmag
250
21k
Mobile First: as difficult as doing things right
swwweet
222
8.9k
Easily Structure & Communicate Ideas using Wireframe
afnizarnur
191
16k
How GitHub (no longer) Works
holman
310
140k
Happy Clients
brianwarren
98
6.7k
Fashionably flexible responsive web design (full day workshop)
malarkey
405
65k
Transcript
(PͰ$-*πʔϧΛ࡞Δʂ
ஸʹͳΓ·͕͢ Θ͍Θ͍͍͖ͬͯ·͠ΐ͏ʂ
w ࠓ$-*πʔϧΛ࡞ΔΛ͢ΔͷͰɼͦΕҎ֎ͷ(PͷͳΔ͘ආ͚ ·͢ɽ ຊ࣭ͱΕͨίʔυ͕૿͑ΔͷͰ w దٓɼ༨ஊͱ֤ͯ͠ϓϥΫςΟεͷิΛ͠·͢ɽ ͓͜ͱΘΓ 3
w ͳͥ(PͰ$-*πʔϧΛ࡞Δͷ͔ w ࠓ࡞Δπʔϧͷ༷Ѳ w ඪ४ϥΠϒϥϦͰ࡞ͬͯΈΔ w Πϯετʔϧͯ͠ΈΔ w ੩తϑΝΠϧΛόΠφϦʹຒΊࠐΉ
w 4DBMBCMFͳ࣮ʹ͢Δ 4DIFEVMF 4
ͳͥ(PͰ$-*πʔϧΛ࡞Δͷ͔
w HIR QFDP (PͰ࡞ΒΕ͍ͯΔπʔϧͨͪ 6
w จ๏͕γϯϓϧ w ίϯύΠϧݴޠ w γϯάϧόΠφϦ w ΫϩείϯύΠϧՄೳ w ίϛϡχςΟ͕׆ൃ
(PͷϝϦοτ 7
w γεςϚνοΫʹݎ࿚ͳαʔϏεΛΉͷۤख ‣ ͦ͏͍͏ͷ3VTUͱ͔ؔܕݴޠͷࣄ ‣ υϝΠϯϩδοΫʹूதͰ͖ͯߴʹαʔϏεΛͤ͞ΒΕΔͷ͕ڧΈ͔ͩΒ (Pͷۤखͳ͜ͱ 8
w IUUQTCFODINBSLTHBNFUFBNQBHFTEFCJBOOFUCFODINBSLTHBNF GBTUFTUHPHQQIUNM w (PίϯύΠϧݴޠ͚ͩͲ($͕Φʔόʔϔουʹͳͬͯগ͍͠ ‣ ͦͷΘΓϝϞϦ҆શ w ͔͠͠։ൃͱ࣮ߦ͕ͪΐ͏Ͳ͍͍
9
ααοͱ࡞Γ͍ͨ࣌ʹ બ͞ΕΔͷ͕(PMBOH
ࠓ࡞Δπʔϧͷհ
w EBJMZSFQP ‣ ใͷܗ࡞πʔϧ ‣ BEEαϒίϚϯυͰςϯϓϨʔτʹैͬͨϨϙʔτ࡞ - dailyrepo add --name
[name] w ࠓճงғؾΛ௫ΉͨΊʹػೳ࠷ݶ ใܗ࡞πʔϧ 12
࣮͍ͯ͘͠લʹ ͱ͜ΖͰօ͞Μ
งғؾͰ$-*πʔϧ ࡞͍ͬͯ·ͤΜ͔ʁ
࣮ͦΕɼϚφʔҧ͔
w ҾͲͷΑ͏ʹઃܭ͢Δ͖ʁ w ϑΝΠϧͷѻ͍Ͳ͏͢Δ͖ʁ w &YJU4UBUVTԿΛฦ͖͢ʁ w ࠔͬͨͱ͖ʹಡΉEFFFFU͞ΜͷૉΒ͍͠ࢿྉ ‣ IUUQTTQFBLFSEFDLDPNUDOLTNLPNBOEPSBJOUVSVOJUVJUFZVSVUPLJOJQV
GBMTFZVSVLPUPOVNCFSZBQDBTJB ‣ PQUJPOTͱBSHVNFOUTͷҐஔ͕ؔೖΕସΘͬͯΔͷΑ͘ݟΔ ࣮͢Δͱ͖ʹߟ͑Δ͜ͱ 16
104*9(/6TUZMF
w IUUQTQVCTPQFOHSPVQPSHPOMJOFQVCT w IUUQTXXXHOVPSHTPGUXBSFMJCDNBOVBMIUNM@NPOPMJCDIUNM w 6OJYΛ࢝Ίͱ֤ͨ͠छ04ؒͰҠ২͍͢͠ΞϓϦέʔγϣϯΛ ࡞ΔͨΊͷࠃࡍن֨ w ͍ͭ͜ΒͷৼΔ͍Λਅࣅ͓͚ͯ͠จ۟ݴΘΕͳͦ͞͏ 104*9(/6TUZMF
18
w "MMQSPHSBNTTIPVMETVQQPSU ‣ --version ‣ --help w MPOHPQUJPOΛ͏ w TIPSUPQUJPOΛ͏
‣ ϑϥάͷ߹·ͱΊΔ͜ͱ͕Ͱ͖ΔΑ͏ʹ FHls -al ‣ ҾΛऔΔ߹ɼؒʹεϖʔεΛͬͯΘͳͯ͘ྑ͍ FHmysql -uroot w IUUQTXXXHOVPSHTPGUXBSFMJCDNBOVBMIUNM@OPEF"SHVNFOU4ZOUBYIUNM 'MBH0QUJPOT 19
w جຊతʹ͕ޭͰ͕ࣦഊ w "EWBODFE#BTI4DSJQUJOH(VJEFʹࡌ͍ͬͯΔن֨ ‣ IUUQUMEQPSH-%1BCTIUNMFYJUDPEFTIUNM ‣ Ͳ͏ͤTIͰ࣮ߦ͢Δͱ͖CJOCBTIΛࢦఆ͢Δ͜ͱ͕ଟ͍͠ w 'SFF#4%ϥΠϒϥϦؔϚχϡΞϧ
‣ IUUQTLBXPSVKQOPSHEPD'SFF#4%KNBONBOTZTFYJUTQIQ w ͋Μ·ΓϋϯυϦϯάͯ͠ΔΞϓϦέʔγϣϯݟͨ͜ͱແ͍͚Ͳ &YJU4UBUVT 20
w 9%(#BTF%JSFDUPSZ ‣ IUUQTTUBOEBSETGSFFEFTLUPQPSHCBTFEJSTQFDMBUFTUJOEFYIUNM ‣ πʔϧͷઃఆϑΝΠϧΩϟογϡΛͲ͜ʹஔ͔͘Λఆ༷ٛͨ͠ॻ )0.&DPOpHͱ͔ w Ұ࣌తͳϑΝΠϧUNQʹஔ͘͜ͱଟ͍
6OJYɾ-JOVYܥ ϑΝΠϧͷѻ͍ 21
– @mygwdesign lσβΠϯར༻͢ΔͷɻΞʔτؑ͢Δͷɻz
$-*ΛσβΠϯ͠·͠ΐ͏
Ͱ͍࣮͟ʂ
w (JU)VCʹࠓͷϦϙδτϦΛ࡞͍ͬͯͩ͘͞ ‣ ࡞ͨ͠πʔϧΛ(JU)VC͔ΒΠϯετʔϧ͢Δͱ͖ʹ͍·͢ w ࠓͷܗ ‣ IUUQTHJUIVCDPNUBYJPHPDMJUVUPSJBM ‣ ໎ͬͨΒ͜͜Λࢀߟʹίϐϖ͍ͯͩ͘͠͞
w ϋϯζΦϯͳͷͰ͔Βͳ͍߹ͲΜͲΜखΛ্͍͛ͯͩ͘͞ ‣ ͚ͩͰख͕·ΘΒͳ͍͜ͱ͋ΔͷͰɼ ྡͷਓ͕ࠔ͍ͬͯΔ߹ڭ͍͑ͯ͋͛ͯͩ͘͞ ࡞͍ͬͯ͘ʹ͋ͨͬͯ 25
ඪ४ϥΠϒϥϦͰ࣮ͯ͠ΈΔ
w qBH ‣ IUUQTHPMBOHPSHQLHqBH ‣ ίϚϯυϥΠϯҾͰ͞ΕΔϑϥάͷύʔεपΓΛཧͯ͘͠ΕΔ ‣ ͱͯബ͍ϥΠϒϥϦͳͷͰͥͻιʔεΛݺΜͰงғؾΛ௫ΜͰΈ·͠ΐ͏ ϥΠϒϥϦհ 27
w ܗIUUQTHJUIVCDPNUBYJPHPDMJUVUPSJBMCMPCNBTUFSDNE EBJMZSFQPNBJOHP ‣ TUBUJLύοέʔδΛͬͯΔͷҰ୴ແࢹͯ͠ɼJPVUJM3FBE'JMF Λ͍ͬͯͩ͘͞ w σϑΥϧτͷqBHΦϒδΣΫτΛ͏ͱFSSPS)BOEMJOHʹ&YJU0O&SSPS͕ ઃఆ͞Ε͍ͯΔͷͰɼIFMQग़ྗ࣌ʹFYJUTUBUVTͰऴྃͯ͠͠·͏ ‣
AIA AIFMQAΛࣗͰఆٛ͢Εͳ͍ ࣮͢Δ 28
-JWF$PEJOH
w MPOHPQUJPOͰ͖·͢ ‣ IUUQNBUPQFIBUFOBCMPHDPNFOUSZ ‣ εϚʔτͰͳ͍ w TIPSUPQUJPO·ͱΊΕͳͦ͞͏ ‣ Βͳ͍͚ͩͰɼ͔ͨ͠͠ΒͰ͖Δ͔
w ͦͦ(Pࣗମ͕ͦ͏͍͏$-*Λఏڙ͍ͯ͠ͳ͍ qBHͰ104*9(/6TUZMFͳ$-*࡞Εͳ͍ʁ 30
Πϯετʔϧͯ͠ΈΔ
w go install͢Δͱ(01"5)CJOҎԼʹόΠφϦ͕ஔ͔ΕΔ w NBJOύοέʔδͷ͋ΔϦϞʔτϦϙδτϦΛgo getͯ͠0, ‣ HPHFUHJUIVCDPNUBYJPHPDMJIBOETPODNEEBJMZSFQP ‣ IUUQTHPMBOHPSHDNEHPIES
%PXOMPBE@BOE@JOTUBMM@QBDLBHFT@BOE@EFQFOEFODJFT w όΠφϦ໊ʁ ‣ NBJOύοέʔδͷ͋ΔσΟϨΫτϦ໊ )PXUPJOTUBMM 32
w (PͰखܰʹΫϩείϯύΠϧͰ͖Δͷ͕ڧΈͰͨ͠Ͷ ‣ GOOS={{OS໊}} GOARCH={{ΞʔΩςΫνϟ໊}} go build ‣ (PΠϯετʔϧ࣌ʹଞڥͷґଘೖΕ͓͚ͯ͜Ε͚ͩͰΫϩείϯύΠϧՄೳ ͷ
ͣ ‣ $(0ΛແޮԽ͓͚ͯ͠ɼTUBUJDMJOLͰ͖Δ CGO_ENABLED=0 ‣ ରԠڥIUUQTHPMBOHPSHEPDJOTUBMMTPVSDFFOWJSPONFOU w $*ͰόΠφϦੜͯ͠ɼ(JU)VCͷ3FMFBTFʹࡌͤΔͷ͕Α͋͘Δӡ༻ํ๏ ‣ (P3FMFBTFSΛ͏ͱָ ‣ IUUQTHJUIVCDPNHPSFMFBTFSHPSFMFBTFS ‣ IUUQTHPSFMFBTFSDPNDJ )PXUPDSPTTDPNQJMF 33
σΟϨΫτϦߏʹ͍ͭͯ 34 /Project main.go # package main lib/ dailyrepo.go #
package dailyrepo w ެ։͍ͨ͠ϓϩδΣΫτ͕πʔϧͳͷ͔ϥΠϒϥϦͳͷ͔ʹΑͬͯɼ σΟϨΫτϦߏେ͖͘มΘΔɽ ‣ ࢀߟΈΜͳͷ(Pݴޠ ࠓվగ൛͕ग़ΔΒ͍͠Ͱ͢ w Ϣʔβ͕go getͨ࣌͠ͷҙਤ͠ͳ͍JOTUBMMΛճආͤ͞Δ /Project dailyrepo.go # package dailyrepo cmd/ dailyrepo/ main.go # package main πʔϧ όΠφϦ ͕ϝΠϯͷՌͷ߹ ϥΠϒϥϦ͕ϝΠϯͷՌͷ߹
੩తϑΝΠϧΛຒΊࠐΉ
w (PͷڧΈͷ̍ͭʹγϯάϧόΠφϦͱ͍͏ͷ͕͋ͬͨ ‣ ੩తϑΝΠϧʹґଘ͢Δπʔϧͩͬͨ߹ɼͦͷϑΝΠϧΠϯετʔϧ࣌ʹ μϯϩʔυͤ͞Δͷʁ ‣ όΠφϦʹຒΊࠐΜ͡Ό͑ w SE1BSUZͷϥΠϒϥϦΛ࣮ͬͯ͢Δ ‣
KUFFVXFOHPCJOEBUBͱ͍͏ͷ͕͕͋ͬͨࠓ%FQSFDBUFE ͱ͍͏͔࡞ऀ͕(JU)VCΞΧϯτΛফͨ͠ ‣ "XFTPNF(PΛݟͯ୳ͦ͏ IUUQTBXFTPNFHPDPNSFTPVSDFFNCFEEJOH ຒΊࠐΉ 36
ҰԠެࣜͬΆ͍Γํʁ 37 $ go build -ldflags "-X main.Version=v0.0.1" w SE1BSUZʹཔΒͳͯ͘όΠφϦʹ੩తϑΝΠϧຒΊࠐΊΔ
w #VJME࣌ʹมʹΛຒΊࠐΉ͜ͱ͕Ͱ͖Δ ‣ (JUͷใΛऔͬͯ7FSTJPOΛຒΊࠐΉͷΑ͘ݟΔ w ͍Ͱ͜ΕͰϑΝΠϧͷ༰ΛຒΊࠐΉͷਏ͍
w IUUQTHJUIVCDPNSBLZMMTUBUJL w ੩తϑΝΠϧͷ[JQσʔλ όΠτྻ Λ(PίʔυͷதʹϋʔυίʔσΟϯά ͍ͯ͠Δɽ ‣ *TUIJTBDSB[ZJEFB /P
OPUOFDFTTBSZ SBLZMMTUBUJL 38
TUBUJLͰຒΊࠐΜͰΈΔ 39 # install $ go get github.com/rakyll/statik # ϑΝΠϧ࡞
$ statik --src=templates/ w ͖ͬ͞ͷςϯϓϨʔτϑΝΠϧಡΈࠐΈΛࠩ͠ସ͑·͠ΐ͏ ‣ IUUQTHJUIVCDPNUBYJPHPDMJUVUPSJBMCMPCNBTUFSDNEEBJMZSFQPNBJOHP
TUBUJLͰຒΊࠐΜͰΈΔ 40 bptl, err := ioutil.ReadFile("../../templates/report.md.tmpl") statikFs, err := fs.New()
if err != nil { log.Fatal(err) } tplFile, err := statikFs.Open("/report.md.tmpl") if err != nil { log.Fatal(err) } defer tplFile.Close() btpl, err := ioutil.ReadAll(tplFile)
-JWF$PEJOH
͜͜ͰҰ୴ʂ
Ͱػೳ͕૿͖͑ͯͨΒʁ ͜ͷϑϥάཧͰεέʔϧͰ͖Δ
4DBMBCMFͳ࣮ʹม͑Δ
w ϑϥάͷύʔαʔΛͬͱݡ͍ͷʹ͢Δ ‣ ྲྀੴʹTIPSU MPOHPQUJPOཉ͍͠ ‣ TIPSUPQUJPOΛ·ͱΊ͍ͨ w ςετ͍͢͠Α͏ʹ͢Δ ‣
ϑΝΠϧγεςϜૢ࡞ͩͬͯςετ͍ͨ͠ ‣ ඪ४ग़ྗͩͬͯςετ͍ͨ͠ ํ 45
None
w ͜ͷਓͷੈք؍ʹै͑େମඞཁͳػೳἧ͏ w QqBH ‣ 104*9(/6TUZMF४ڌͳqBHΑΓͪΐͬͱݡ͍ϑϥάύʔαʔ w DPCSB ‣ QqBHΛϕʔεʹ࡞ΒΕͨ$-*ϑϨʔϜϫʔΫ
w BGFSP ‣ ϑΝΠϧγεςϜͷநԽϥΠϒϥϦ w WJQFS ‣ ઃఆϑΝΠϧཧϥΠϒϥϦ TQGͱ͍͏εΰ͍ਓ 47
·ͣDPCSBͰ࣮͍ͯ͘͠ 48 # install $ go get github.com/spf13/cobra # init
$ cobra init dailyrepo --pkg-name github.com/{Ϣʔβʔ໊}/{ϦϙδτϦ໊}/cmd/dailyrepo # create `add` sub command $ cobra add add w ؤு͖ͬͯͬ͞ͷ࣮Λ࠶ݱ ‣ IUUQTHJUIVCDPNUBYJPHPDMJUVUPSJBMUSFFNBTUFSDNEEBJMZSFQPFY
-JWF$PEJOH
w IUUQTHJUIVCDPNBWFMJOPBXFTPNFHPTUBOEBSEDMJ w Α͘ฉͭ͘ ‣ KFTTFWELHPqBHT ‣ BMFDUIPNBTLJOHQJO ‣ VSGBDFDMJ
‣ NJUDIFMMIDMJ QqBH DPCSBҎ֎ͷબࢶ 50
TQGBGFSP 51 # install $ go get github.com/spf13/afero w IUUQTHJUIVCDPNTQGBGFSP
w ϑΝΠϧγεςϜͷૢ࡞ΛநԽͯ͘͠ΕΔϥΠϒϥϦ ‣ BGFSP'T0T04ଆͷϑΝΠϧγεςϜ ‣ BGFSP.FN.BQ'TϝϞϦ্ʹߏங͞ΕͨϑΝΠϧγεςϜ ςετ࣌ʹ͏
-JWF$PEJOH
w GNU1SJOUMO PT4UEPVUʹରͯ͠GNU'QSJOUMO ͍ͯ͠Δɽ ‣ PT4UEPVUΛCZUFT#V⒎FSʹࠩ͠ସ͑ΕΔΑ͏ʹ͓ͯ͘͠ w ࠓճWFSTJPOͷQSJOUΛςετͯ͠Έ·͢ ඪ४ग़ྗΛςετ͢Δ 53
-JWF$PEJOH
ʂ
w HJUIVCDPNTQGWJQFS ‣ ίϚϯυϥΠϯϑϥάɼڥมɼઃఆϑΝΠϧ KTPO UPNM ZBNM FUD ɼ ϦϞʔτઃఆγεςϜ
FUDE FUD ɼσϑΥϧτ͔ΒઃఆΛऔಘ͢Δɽ w os.UserHomeDir, os.UserCacheDir, os.UserConfigDir ͜Ε·ͩϦϦʔε͞Εͯͳ͍ Λͬͯ ઃఆϑΝΠϧΛݟ͚ͭΑ͏ ༨ஊઃఆϑΝΠϧͷ 56
w ࠷ۙͷπʔϧ݁ߏ(PͰॻ͔Ε͍ͯΔ w (Pͩͱ࡞࣌࡞ޙ͍͍͢$-*πʔϧΛ࡞Δ͜ͱ͕Ͱ͖Δ w டংͷແ͍$-*Ξʔτ ·ͱΊ 57
w MPHHJOH ‣ cobra.OnInitialize()ͰWFSCPTFͷਅِΛݟͯMPHͷઃఆΛม͑ͨΓ͢Δ w ΞʔΩςΫνϟ ‣ جຊతʹࠓͷϑΝΠϧγεςϜඪ४ग़ྗͷநԽͷΑ͏ͳΠϝʔδͰ ͦΕͧΕͷΛશ͏͢ΔϞδϡʔϧΛநԽ͍ͯ͘͠ ‣
(PͰ"1*αʔόʔΛ࣮͢Δͱ͖ϨΠϠʔυΞʔΩςΫνϟ͕Α͘࠾༻͞Ε·͢ w ΤϥʔϋϯυϦϯά ‣ (PͰYFSSPST͕ඪ४ͷFSSPSTʹΈࠐ·ΕΔΒ͍͠Ͱ͢ IUUQTHPHPPHMFTPVSDFDPNQSPQPTBM NBTUFSEFTJHOFSSPSWBMVFTNE ‣ ϋϯυϦϯάʹ͍ͭͯIUUQTNFEJVNDPNZBLLBCFUUFSHPFSSPSIBOEMJOHXJUI YFSSPSTFD ࠓͯ͠ͳ͍༰ 58
w HP[(Pʹؔ͢Δχϡʔε·ͱΊ ‣ IUUQHP[IFYBDPTBOFU w HPXJLJ৭ʑͳϓϥΫςΟε͕·ͱ·͍ͬͯΔ ‣ IUUQTHJUIVCDPNHPMBOHHPXJLJ w 5IF(P#MPHެࣜΞφϯεͱ͔
‣ IUUQTCMPHHPMBOHPSH ༨ஊ(PΛֶͼ͍ͨͳΒ 59
Ҏ্ʂ ͓ർΕ༷Ͱͨ͠ʂ