Slide 1

Slide 1 text

GoͰͷνʔϜ։ൃʹ్தࢀըͨ͠ࢲ͕ ೲಘ࣮ͯ͠૷ΛਐΊΔͨΊʹ΍ͬͨ͜ͱ ~ ໋໊ฤ ~ 2024/06/07@(Unofficial) Go Conference 2024 Pre Party

Slide 2

Slide 2 text

ࣗݾ঺հ 2 Kaoru Muta ໂా ܆ (ϝϯτε) ੜ·ΕҭͪେࡕͰࠓ΋େࡕʹ͍·͢ 2024೥2݄ʹגࣜձࣾBuySell Technologies join. ങऔج൫/๚໰ങऔʹಛԽͨ͠αʔϏεͷ৽ن։ൃʹैࣄ ങऔɾࠪఆ ങऔछผʹԠͨ͡࠷దͳγεςϜߏங Visit -๚໰ങऔ- Store -ళฮങऔ- ങऔ ϦϢʔεϓϥοτϑΥʔϜCosmos ࣗࣾ։ൃͷϦϢʔεಛԽۀ຿جװγεςϜͰ͋ΓαʔϏε܈ͷू߹ମ @m_t_tion1

Slide 3

Slide 3 text

ຊൃදͷཁ఺ͱϞνϕʔγϣϯ 3 ʮڷ (=Go)ʹೖΒ͹ڷʹै͑ʯΛνʔϜͰୡ੒͢ΔͨΊʹ ίʔσΟϯάʹؔ͢Δҙࢥ౷ҰΛνʔϜ಺ͰߦͬͨΒɺ ίʔυʹҰ؏ੑ͕ग़ͨ & ϨϏϡʔίετͱ೰ΈϙΠϯτ͕গͳ͘ ͳͬͨ࿩ ཁ఺ Ϟνϕ ҎԼͷ఺Λօʹฉ͍ͯΧδϡΞϧʹσΟεΧογϣϯ͍ͨ͠ ● ౰ൃදͰऔΓ্͛Δࣄ৅ʹࣅͨૺ۰ͨ͜͠ͱ͕͋Δ͔ ○ ૺ۰ͨ͠৔߹͸ɺͲ͏ରॲ͔ͨ͠ ○ ͠ͳ͔ͬͨ৔߹͸ɺެࣜͷϧʔϧʹै͏ͷΈͰ े෼ͩͬͨͷ͔

Slide 4

Slide 4 text

ΦϯϘʔσΟϯά࣌ͷܦݧ 4 ● ࠓ·ͰJavaϝΠϯͰॻ͍͍ͯͨΤϯδχΞ ● GoͰ࡞͍ͬͯΔ0 → 1ͷ৽ن։ൃͷ్தͰJOIN ● طଘίʔυΛ֬ೝ͠ΩϟονΞοϓ ঢ়گ ײ૝ ● Go͸දݱੑ͕௿͘ɺॻ͖ํͷ͹Β͖ͭ͸গͳ͍͸ͣ (গͳ͘ͱ΋JavaΑΓ͸) ͔͠͠ɺҎԼͷ఺Ͱ͹Β͖͕ͭɾɾ ○ ม਺໊ͷলུͷ࢓ํ ○ ϙΠϯλͷ࢖͍ॴ...etc ίʔυϨϏϡʔͷίετ૿Ճ, ॻ͖ํʹ໎͍͕ੜ͡ΔՄೳੑ

Slide 5

Slide 5 text

ΦϯϘʔσΟϯά࣌ͷܦݧ 5 ● ࠓ·ͰJavaϝΠϯͰॻ͍͍ͯͨΤϯδχΞ ● GoͰ࡞͍ͬͯΔ0 → 1ͷ৽ن։ൃͷ్தͰJOIN ● طଘίʔυΛ֬ೝ͠ΩϟονΞοϓ ঢ়گ ײ૝ ● Go͸දݱੑ͕௿͘ɺॻ͖ํͷ͹Β͖ͭ͸গͳ͍͸ͣ (গͳ͘ͱ΋JavaΑΓ͸) ͔͠͠ɺҎԼͷ఺Ͱ͹Β͖͕ͭɾɾ ○ ม਺໊ͷলུͷ࢓ํ ○ ϙΠϯλͷ࢖͍ॴ...etc ίʔυϨϏϡʔͷίετ૿Ճ, ॻ͖ํʹ໎͍͕ੜ͡ΔՄೳੑ ຊൃදͷτϐοΫ

Slide 6

Slide 6 text

6 Έͳ͞Μಉ͡Α͏ͳײ૝Λ ࣋ͬͨ͜ͱ͸͋Γ·͔͢ʁ

Slide 7

Slide 7 text

7 ౰࣌ͷࢲͷ৔߹

Slide 8

Slide 8 text

8 Goͷࢥ૝Λ஌ΔͨΊʹ Ұ୴ެࣜdocͱؔ࿈ࢿྉΛړΖ͏

Slide 9

Slide 9 text

9 Effective GoͱGo styleguideͰͷߟ͑ํ ~ʮաෆ଍ͳ͍ʯ໋໊ʹ͍ͭͯ ~

Slide 10

Slide 10 text

Effective Go - #names ● ৑௕ͳ໋໊͸ආ͚Δ΂͖ 10 ref: https://go.dev/doc/effective_go#names Good :+1: Bad :-1:

Slide 11

Slide 11 text

Go styleguide - #variable-names ● ʮաෆ଍ͳ͍ʯ (= Clarity / Concision) ໋໊Λ͢΂͖ ○ ม਺͕ࢀর͞ΕΔൣғ (= Scope)ʹԠͯ͡ҟͳΔ ○ লུͯ͠΋୹͍είʔϓͰม਺ͷ໾ׂ͕ࣗ໌ͳΒOK ○ লུͨ͠ม਺Λ௕͍είʔϓͰ࢖͍ճ͢ͱՄಡੑ͕མͪΔͨΊNG 11 *ߦ਺͸ݫ֨ͳ΋ͷͰͳ͘ɺGo styleguideهࡌͷࢀߟͰ঺հ͞Ε͍ͯΔ਺ࣈ ref: https://google.github.io/styleguide/go/decisions#variable-names ୹͍είʔϓͷྫ (*1~7ߦ) ௕͍είʔϓͷྫ (*25ߦ~)

Slide 12

Slide 12 text

ݸਓͷݟղ ● େલఏͱͯ͠GoެࣜͰఏএ͍ͯ͠Δࢥ૝ʹै͏ ● ݸਓ͓ΑͼνʔϜͰʮաෆ଍ͳ໋໊͍ʯͱ͸ΛࡲΓ߹Θͤͨํ͕ ࣮૷ऀɾϨϏϡϫʔͱ΋ʹ޾ͤʹͳΕΔͷͰ͸ʁ ○ ୹͍είʔϓ ■ Ұ࣌తͳม਺ ■ ؔ਺ͷ໊લ΍ฦΓ஋͔Β΋Β͏஋͕ࣗ໌ͳ৔߹ ○ ௕͍είʔϓ ■ ೝ஌ෛՙ্͕͕Γͦ͏ͳ৔߹͸লུ͠ͳ͍ ■ (ͦ΋ͦ΋௕͗͢Δείʔϓ͸ϝιουͱͯ͠ͷ෼ׂΛ ݕ౼͢Δ৔߹΋͋Δ) 12

Slide 13

Slide 13 text

13 νʔϜͰࡲΓ߹ΘͤΔ

Slide 14

Slide 14 text

νʔϜͰͷ߹ҙܗ੒ ● ฐνʔϜͰͷʮաෆ଍ͳ͍ʯͬͯʁ ○ جຊ͸লུ͠ͳ͍ํ਑Ͱɺܕ΍είʔϓ͔Βࣗ໌ͩͱ൑அͨ͠Βলུ͢Δ ○ Defined Type࢖͏৔߹͸ม਺ͷ໾ׂ͕ࣗ໌Ͱ͋ΔͨΊলུͯ͠΋Α͍ (ল໊ུͨ͠લ͸Ұ؏ͯ͠࢖͏͜ͱ) ■ ex. salesContractID → scID bailmentReceiptID → brID ○ ໨҆ͱͯ͠লུ͸࠷େ2୯ޠ·Ͱ ex. salesContractDocumentDetail → scdd ͱ͔͸ආ͚͍ͨ 14

Slide 15

Slide 15 text

ӡ༻ޙͷνʔϜ಺֎͔ΒͷϑΟʔυόοΫ 15 ● νʔϜͰվΊͯGoͷࢥ૝Λ৮ΕֶͯͿ͜ͱ͕Ͱ͖ͨ ● ίʔυʹҰ؏ੑ͕ग़࣮ͯ૷Λ͢Δ্Ͱ໎͍͕ͳ͘ͳͬͨ ● (͜͜͸ݸਓͷײ૝Ͱ͕͢) ίʔυϨϏϡʔͰGoͷࢥ૝ʹؔ࿈ ͢Δ໋໊ʹؔͯ͠ࢦఠ͢Δ͜ͱ͸ݮͬͨ Good More ● ৽نࢀೖऀ͕͖ͨ࣌ʹಉ༷ͷٞ࿦͕ੜ·ΕΔՄೳੑ͕͋Δ ͦͷͨΊఆظతʹݟ௚͢͜ͱ͕ඞཁ͔΋ ○ ຖ౓ม͑Δͷ͸ӡ༻ίετ͕ߴͦ͏ ○ Goͷࢥ૝ʹै͏ͷ͸ม͑ͳ͍͍ͯ͘ ○ ʮաෆ଍ͳ͍ʯΛೝ஌ෛՙɾՄಡੑͷ؍఺Ͱ ఆظతʹ࿩͢ͷ͸Αͦ͞͏

Slide 16

Slide 16 text

ຊൃදͷཁ఺ͱϞνϕʔγϣϯ 16 ʮڷ (=Go)ʹೖΒ͹ڷʹै͑ʯΛνʔϜͰୡ੒͢ΔͨΊʹ ίʔσΟϯάʹؔ͢Δҙࢥ౷ҰΛνʔϜ಺ͰߦͬͨΒɺ ίʔυʹҰ؏ੑ͕ग़ͨ & ϨϏϡʔίετͱ೰ΈϙΠϯτ͕গͳ͘ ͳͬͨ࿩ ཁ఺ Ϟνϕ ҎԼͷ఺Λօʹฉ͍ͯΧδϡΞϧʹσΟεΧογϣϯ͍ͨ͠ ● ౰ൃදͰऔΓ্͛Δࣄ৅ʹࣅͨૺ۰ͨ͜͠ͱ͕͋Δ͔ ○ ૺ۰ͨ͠৔߹͸ɺͲ͏ରॲ͔ͨ͠ ○ ͠ͳ͔ͬͨ৔߹͸ɺެࣜͷϧʔϧʹै͏ͷΈͰ े෼ͩͬͨͷ͔

Slide 17

Slide 17 text

17 Έͳ͞ΜͲ͏ͯ͠·͔͢ʁ

Slide 18

Slide 18 text

Thank You!