Slide 1

Slide 1 text

GoͰςϯϓϨʔτ͔ΒϑΝΠϧΛࣗಈੜ੒͢ΔCLIΛ࡞Δ ʲZOZO x ϕʔεϚΩφ x όΠηϧʳGoษڧձ #1ʲϋΠϒϦου։࠵ʳ 2023.05.24

Slide 2

Slide 2 text

ࣗݾ঺հ ໊લɿૣ੉࿨ً ܦྺɿBuySell Technologiesʹ2021೥ʹ৽ଔೖࣾ ॴଐɿ։ൃ2෦ ग़඼؅ཧSaaSνʔϜ ໾৬ɿϑϧελοΫΤϯδχΞɺϓϩδΣΫτϦʔμʔ झຯɿ։ൃɺϚϯΨɺΞχϝɺϕʔεɺόεέ Twitterɿ@KazukiHayase

Slide 3

Slide 3 text

ΞδΣϯμ CLIΛ࡞੒ͨ͠എܠ 01 ࡞੒ͨ͠CLIͷ঺հ 02 ·ͱΊ 03

Slide 4

Slide 4 text

01 CLIΛ࡞੒ͨ͠എܠ

Slide 5

Slide 5 text

CLIΛ࡞੒ͨ͠എܠ ● ݩʑੜ࢈ੑΛ޲্ͤ͞ΔCLIΛ࡞ΔจԽ͕νʔϜʹ͋ͬͨ ● ϓϩμΫτͷಛੑ্ɺಉ͡Α͏ͳ࣮૷͕ෳ਺Օॴଘࡏ͢Δ ○ ※େ࿮͸ಉ͕ͩ͡ɺڞ௨Խ͸೉͍͠

Slide 6

Slide 6 text

CLIΛ࡞੒ͨ͠എܠ ग़඼؅ཧSaaS͸ෳ਺ͷECαΠτ΁ಉ࣌ग़඼Λߦ͏ ECαΠτ1 ECαΠτ2 ECαΠτ3

Slide 7

Slide 7 text

CLIΛ࡞੒ͨ͠എܠ ECαΠτ͝ͱʹAPI͕ҟͳΔ ECαΠτ1 ECαΠτ2 ECαΠτ3 json xml

Slide 8

Slide 8 text

CLIΛ࡞੒ͨ͠എܠ ● ECαΠτ͝ͱʹAPI͕ҟͳΔͷͰڞ௨Խ͸Ͱ͖ͳ͍ ● มߋ͞ΕΔഎܠ͕ҟͳΔͷͰɺա౓ͳந৅Խ΋ආ͚͍ͨ ● ͨͩ͠ɺॲཧͷେ࿮͸ͲͷECαΠτ΋େମ͸ಉ͡ ςϯϓϨʔτ͔ΒϑΝΠϧΛੜ੒ͯ͠ ࣮૷Λޮ཰Խ͍ͨ͠ʂʂ

Slide 9

Slide 9 text

02 ࡞੒ͨ͠CLIͷ঺հ

Slide 10

Slide 10 text

׬੒෺

Slide 11

Slide 11 text

࣮ߦίϚϯυ ର࿩ܗࣜͰೖྗ

Slide 12

Slide 12 text

ςϯϓϨʔτϑΝΠϧͱੜ੒ϑΝΠϧ ೖྗͨ͠ύοέʔδ໊ͱؔ਺໊Ͱ 
 ஔ׵͞ΕΔ ςϯϓϨʔτϑΝΠϧ ੜ੒ϑΝΠϧ

Slide 13

Slide 13 text

࣮૷

Slide 14

Slide 14 text

࢖༻ͨ͠ϥΠϒϥϦ ● cobra ○ CLIΛ؆୯ʹ࡞੒Ͱ͖ΔϥΠϒϥϦ ○ Kubernetes΍GitHub CLIͰ΋࢖༻͞Ε͍ͯΔ ● text/template ○ ςϯϓϨʔτΛݩʹจࣈྻΛੜ੒͢Δඪ४ϥΠϒϥϦ ○ ؔ਺΍ม਺ɺfor΍ifͳͲͷ੍ޚߏจ΋ςϯϓϨʔτʹຒΊࠐΊΔ

Slide 15

Slide 15 text

େ࿮ͷ࡞੒ cobra-cliΛར༻ͯ͠ 
 ϘΠϥʔςϯϓϨʔτΛ࡞੒ cmdύοέʔδʹCLIͷॲཧΛ ࣮૷͍ͯ͘͠

Slide 16

Slide 16 text

ίϚϯυͷ௥Ճ cobra.Commandߏ଄ମΛఆٛ rootCmdʹ௥Ճ͢Δ͜ͱͰ 
 CLI͔Β࣮ߦͰ͖ΔΑ͏ʹͳΔ

Slide 17

Slide 17 text

ඪ४ೖྗͷऔಘ fmt.ScanlnͰඪ४ೖྗΛऔಘ ඪ४ೖྗΛݩʹςϯϓϨʔτʹ ౉͢σʔλΛmapͰఆٛ

Slide 18

Slide 18 text

ೖग़ྗϑΝΠϧͷఆٛ ςϯϓϨʔτϑΝΠϧͱग़ྗઌͷ ϑΝΠϧΛmapͰఆٛ ֤ೖग़ྗʹରͯ͠ϧʔϓͰॲཧ

Slide 19

Slide 19 text

ϑΝΠϧͷಡΈࠐΈͱੜ੒ ςϯϓϨʔτΛಡΈࠐΈɺ 
 ग़ྗઌͷϑΝΠϧΛੜ੒

Slide 20

Slide 20 text

ςϯϓϨʔτͷஔ׵ ಡΈࠐΜͩςϯϓϨʔτʹରͯ͠ ඪ४ೖྗͰड͚औͬͨσʔλΛ 
 ࢖༻ͯ͠ஔ׵ॲཧΛ࣮ߦ

Slide 21

Slide 21 text

ςϯϓϨʔτϑΝΠϧͷྫ

Slide 22

Slide 22 text

03 ·ͱΊ

Slide 23

Slide 23 text

·ͱΊ ● cobraͱtext/templateͰ؆୯ʹࣗಈੜ੒CLIΛ࡞Εͨ ○ ੍ޚߏจ΋ར༻Ͱ͖ΔͷͰɺςϯϓϨʔτ΋ॊೈʹఆٛՄೳ ● CLIΛ࡞੒ͨ͜͠ͱͰ࣮૷Λޮ཰Խ͢Δ͜ͱ͕Ͱ͖ͨ ● σΟϨΫτϦߏ੒ͳͲͷϧʔϧͷڧ੍ʹ΋׆༻Ͱ͖Δ ○ ϧʔϧʹैͬͨςϯϓϨʔτΛఆٛ͢Δ͜ͱͰɺ 
 ࣗવͱϧʔϧʹै࣮ͬͨ૷ʹͳΔΑ͏ʹ࢓૊ΈԽͰ͖Δ

Slide 24

Slide 24 text

THANK YOU