Goのソースコードから読み解くオブジェクト指向プログラミング@Object-Oriented Conference 2020

Dd54ef589676aa4bf9e09d72c61bb80e?s=47 arakawa
February 11, 2020

Goのソースコードから読み解くオブジェクト指向プログラミング@Object-Oriented Conference 2020

Dd54ef589676aa4bf9e09d72c61bb80e?s=128

arakawa

February 11, 2020
Tweet

Transcript

  1. 0CKFDU0SJFOUFE$POGFSFODF !͓஡ͷਫঁࢠେֶڞ (Pͷιʔείʔυ͔ΒಡΈղ͘ ΦϒδΣΫτࢦ޲ϓϩάϥϛϯά BETIPMPLP BETIPMPLP

  2. ࣗݾ঺հ 4IPHP"SBLBXB J04&OHJOFFS !4BOTBO BETIPMPLP BETIPMPLP

  3. ࠓ೔࿩͢͜ͱ w (Pͷιʔείʔυͷઃܭ͔ΒΦϒδΣΫτࢦ޲ͷΤοηϯεΛֶ΅͏ w ΦϒδΣΫτࢦ޲ͷҰ୺Ͱ͋ΔσβΠϯύλʔϯʹ͍ͭͯ࿩͠·͢ ϘτϜΞοϓͰΦϒδΣΫτࢦ޲ͷਅ਷ΛֶͿ

  4. (Pʹ͍ͭͯ w (PPHMF͕։ൃͨ͠ݴޠ w ೥݄ʹॳϦϦʔε w 3PC1JLFɺ,FO5PNQTPOʢݩ6/*9 ։ൃऀʣΒ͕ॳظઃܭͨ͠੩తܕ෇͚ݴޠ w ͭ·Γ6/*9ͷΤοηϯε͕٧·͍ͬͯΔ

  5. ͦ΋ͦ΋ʜ (P͸ΦϒδΣΫτࢦ޲ݴޠ͔ʁ

  6. (P͸ΦϒδΣΫτࢦ޲ݴޠʁ https://golang.org/doc/faq

  7. (P͸ΦϒδΣΫτࢦ޲ݴޠʁ https://golang.org/doc/faq

  8. l:FTBOEOP"MUIPVHI(PIBTUZQFTBOENFUIPETBOE BMMPXTBOPCKFDUPSJFOUFETUZMFPGQSPHSBNNJOH UIFSF JTOPUZQFIJFSBSDIZ5IFDPODFQUPGlJOUFSGBDFzJO(P QSPWJEFTBEJGGFSFOUBQQSPBDIU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Ήʯ͜ͱ͕ڞ௨͍ͯ͠Δ
  20. ྫόοϑΝϦϯά͋ΓϑΝΠϧಡΈࠐΈ ˞্ه͸JPVUJM3FBE'JMFͱ͍͏ศརϝιουͰ΋୅ସՄೳ ʢόοϑΝ֬อͷαΠζ͸ҟͳΔʣ

  21. 3FBEFSΛ૊Έ߹ΘͤΔ CVpP3FBEFS JOUFSGBDF JP3FBEFS JOUFSGBDF JP3FBEFS PT'JMF

  22. ୯७Խ͢Δͱʜ JOUFSGBDF JP3FBEFS CVpP3FBEFS PT'JMF CVpP3FBEFS͕JP3FBEFSΛϥοϓͰ͖Δߏ଄

  23. w JP3FBEFSΛϑΟʔϧυʹ࣋ͭ w ϑΟʔϧυʹ୅ೖ͞Ε͍ͯΔ۩৅Ϋ ϥεʹ͸Ұ੾ؔ༩͠ͳ͍ CVpPHP CVpP3FBEFS

  24. ϑΝΠϧʹͯ͠΋ 3FBEFS͑͞ܧঝ͍ͯ͠Ε͹ ԿͰ΋ࠩ͠ସ͑ΒΕΔ CVpP3FBEFS JOUFSGBDF JP3FBEFS JOUFSGBDF JP3FBEFS PT'JMF

  25. ίωΫγϣϯʹͯ͠΋ 3FBEFS͑͞ܧঝ͍ͯ͠Ε͹ ԿͰ΋ࠩ͠ସ͑ΒΕΔ CVpP3FBEFS JOUFSGBDF JP3FBEFS JOUFSGBDF JP3FBEFS OFU*1$POO

  26. ࣗ࡞3FBEFSʹͯ͠΋ 3FBEFS͑͞ܧঝ͍ͯ͠Ε͹ ԿͰ΋ࠩ͠ସ͑ΒΕΔ CVpP3FBEFS JOUFSGBDF JP3FBEFS JOUFSGBDF JP3FBEFS ࣗ࡞3FBEFS

  27. "UPVSPG(P305

  28. JP3FBEFSͷԿ͕خ͍͔͠ʁ w ݺͼग़͠ݩ͔Β͢Ε͹ಡΈग़͠ݩͷιʔεΛҰ੾ҙࣝͤͣʹ͢Ή w JP3FBEFSʹ४ڌ͢Δͱಁաతʹ༷ʑͳػೳΛ֦ு͢Δ͜ͱ͕ग़དྷΔ w FH όοϑΝ͋Γ ϑΝΠϧιέοτ૊Έ߹Θͤ͸ແݶେʂ ˞(P'ͷσβΠϯύλʔϯͰݴ͑͹$PNQPTJUF4UBSBUFHZύλʔϯʹ͍͔ۙ΋

  29. w ಡΈࠐΈॲཧΛಁաతʹѻ͏ͨΊͷ3FBEFSʢඪ४ϥΠϒϥϦΑΓʣ w ໦૸ࠪΛݡ͘ಁաతʹѻ͏ͨΊͷ7JTJUPSʢݴޠॲཧܥΑΓʣ ࠓճ঺հ͢Δύλʔϯ

  30. ίϯύΠϥͷಈ͖ ιʔείʔυ ࣈ۟ղੳ ߏจղੳ ҙຯղੳ ࠷దԽ ࣮ߦϑΝΠϧग़ྗ ˞࣮ࡍ͸΋͏গ͠ෳࡶͰ͢

  31. ίϯύΠϥͷಈ͖ ̑    ιʔείʔυ ࣈ۟ղੳ ߏจղੳ ҙຯղੳ ࠷దԽ

    ࣮ߦϑΝΠϧग़ྗ <̑      >
  32. ίϯύΠϥͷಈ͖ ιʔείʔυ ࣈ۟ղੳ ߏจղੳ ҙຯղੳ ࠷దԽ ࣮ߦϑΝΠϧग़ྗ <̑  

        >    ˎ
  33. ίϯύΠϥͷಈ͖ ιʔείʔυ ࣈ۟ղੳ ߏจղੳ ҙຯղੳ ࠷దԽ ࣮ߦϑΝΠϧग़ྗ   

    ˎ ׂѪ
  34. ໦ߏ଄Λ८ճ͍ͨ͠    ˎ ໦Λ͍͍ײ͡ʹ८ճͭͭ͠ɺͦͷϊʔυʹैͬͨॲཧΛ͍ͨ͠

  35. ໦ߏ଄Λ८ճ͍ͨ͠ w 7JTJUPS͸໦Λ८ճ͢Δ w /PEF͸֤અ఺Λදݱ͢Δ w &YQS͸/PEFΛ֦ுͨ͠Πϯ λʔϑΣʔε BTUXBMLHP BTUBTUHP

  36. /PEFͷछྨͨͪ   ˎ  /PEF

  37. /PEFͷछྨͨͪ   ˎ  &YQS

  38. /PEFͷछྨͨͪ JOUFSGBDF /PEF JOUFSGBDF &YQS JOUFSGBDF %FDM #BTJD-JU FH ੔਺Ϧςϥϧ

    #JOBSZ&YQS FH ೋ߲ԋࢉࢠ *EFOU FH ม਺ ʜ JOUFSGBDF 4UNU
  39. /PEFͷछྨͨͪ   ˎ  #JOBSZ&YQS #BTJD-JU

  40. #BTJD-JU

  41. #JOBSZ&YQS

  42. ८ճ 8BML ͷಈ͖    ˎ 7JTJUPS

  43. ८ճ 8BML ͷಈ͖    ˎ 7JTJUPS

  44. ८ճ 8BML ͷಈ͖    ˎ 7JTJUPS

  45. ८ճ 8BML ͷಈ͖    ˎ 7JTJUPS 9 :

  46. ८ճ 8BML ͷಈ͖    ˎ 7JTJUPS 9 :

  47. ८ճ 8BML ͷಈ͖    ˎ 7JTJUPS

  48. ८ճ 8BML ͷಈ͖    ˎ 7JTJUPS 9 :

  49. ८ճ 8BML ͷಈ͖    ˎ 7JTJUPS

  50. ८ճ 8BML ͷಈ͖    ˎ 7JTJUPS 9 :

  51. ८ճ 8BML ͷಈ͖    ˎ 7JTJUPS

  52. Կ͕خ͍͠ͷ͔ʁ w ८ճͱ๚໰࣌ͷϊʔυૢ࡞ͷ੹຿ͷ෼཭͕Ͱ͖Δ͜ͱ w ८ճ͸Ͳͷछྨͷϊʔυ͔ʹ͸ؔ༩ͤͣಁաతͳΞΫηε͕Ͱ͖Δ w ֤ϊʔυ͝ͱʹઐ༻ͷॲཧΛॻ͘ͷͰίʔυͷݟ௨͕͠ྑ͍ w ϊʔυૢ࡞ʢ7JTJUʣΛϢʔβ͕֦ு͢Δ͜ͱ͕Ͱ͖Δ ˞(P'ͷσβΠϯύλʔϯͰݴ͑͹7JTJUPSύλʔϯʹ͍͕ۙɺ׬શʹҰக͍ͯ͠ΔΘ͚Ͱ͸ͳ͍

  53. ࠓճ঺հͨ͠ύλʔϯ w ಡΈࠐΈॲཧΛಁաతʹѻ͏ͨΊͷ3FBEFSʢඪ४ϥΠϒϥϦΑΓʣ w ໦૸ࠪΛݡ͘ಁաతʹѻ͏ͨΊͷ7JTJUPSʢݴޠॲཧܥΑΓʣ

  54. Ͳ͕͜ΦϒδΣΫτࢦ޲ͩͬͨͷ͔ʁ

  55. w ಡΈࠐΈॲཧΛಁաతʹѻ͏ͨΊͷ3FBEFSʢඪ४ϥΠϒϥϦΑΓʣ w ໦૸ࠪΛݡ͘ಁաతʹѻ͏ͨΊͷ7JTJUPSʢݴޠॲཧܥΑΓʣ Ͳ͕͜ΦϒδΣΫτࢦ޲ͩͬͨͷ͔ʁ ݺͼग़͠ݩ͔Βৄࡉͷ࣮૷Λҙࣝ͠ͳ͍ ৄࡉ͸ͦͷੑ࣭͝ͱʹಈ࡞͢Δ

  56. Ͳ͕͜ΦϒδΣΫτࢦ޲ͩͬͨͷ͔ʁ w ಡΈࠐΈॲཧΛಁաతʹѻ͏ͨΊͷ3FBEFSʢඪ४ϥΠϒϥϦΑΓʣ w ໦૸ࠪΛݡ͘ಁաతʹѻ͏ͨΊͷ7JTJUPSʢݴޠॲཧܥΑΓʣ ΧϓηϧԽ ϙϦϞʔϑΟζϜ

  57. ࠷ޙʹ lจ໌ͷਐา͸ɺਓ͕ҙࣝͤͣʹ਱ߦՄೳͳ ॏཁԋࢉͷ਺త֦େʹΑΓ΋ͨΒ͞ΕΔz "MGSFE/PSUI8IJUFIFBEʢ਺ֶऀʣ 

  58. ຊࢿྉ͸TQFBLFSEFDLʹͯެ։ࡁΈͰ͢ BETIPMPLP BETIPMPLP 5IBOLZPV