僕がGoを選ぶ理由

F2ebf0e7d45afa728d5e4b7d697c4ce0?s=47 Koki Natsume
September 23, 2018

 僕がGoを選ぶ理由

Student Go #1 ビギナーズセッション 2 の発表資料です。
僕のGoの好きなところをまとめました。

F2ebf0e7d45afa728d5e4b7d697c4ce0?s=128

Koki Natsume

September 23, 2018
Tweet

Transcript

  1. ๻͕ ɹɹ ΛબͿཧ༝ 4UVEFOU(P ϏΪφʔηογϣϯ

  2. ࣗݾ঺հ ϋϯυϧωʔϜ: natumn/natumndb ֶߍ: ձ௡େֶ ֶ෦3೥ੜ GoͰ΍͍ͬͯΔ͜ͱ: • GAE/Go ʹΑΔαʔόʔαΠυͷ։ൃ

    (ΞϧόΠτ) • CLI, slack botͳͲπʔϧ܈ͷ։ൃ (झຯ) • ֶ಺޲͚ݕࡧΤϯδϯweb-int-searcherͷ։ൃ (େֶͰͷ׆ಈ) • etc…
  3. StudentGoͷϞνϕʔγϣϯ

  4. ΋ͬͱGoΛ޷͖ʹʂ

  5. ࠓ೔࿩͢͜ͱ

  6. ॳ৺ऀͳ๻͕GoֶΜͰ͍͘աఔͰ޷͖ͳͬͨͱ͜Ζ

  7. ໨࣍ •ͳͥGo͸ͭ͘ΒΕͨͷ͔ •͍ͭGoͰ͔͘ͷ͔ •GoΛֶͿ •ੜ࢈ੑΛ͋͛ΔͨΊʹ •·ͱΊ

  8. ͳͥ(P͸ͭ͘ΒΕͨͷ͔ ͳͥGoogle ͸ Go Λ͔ͭͬͨ͘

  9. Go at Google: Language Design in the Service of Software

    Engineering ͳͥ(P͸ͭ͘ΒΕͨͷ͔
  10. URL: https://talks.golang.org/2012/splash.article ͳͥ(P͸ͭ͘ΒΕͨͷ͔

  11. github.com/golang/go/wiki ͳͥ(P͸ͭ͘ΒΕͨͷ͔

  12. golang.org/doc FAQ ͳͥ(P͸ͭ͘ΒΕͨͷ͔

  13. GoogleͰେن໛ͳιϑτ΢ΣΞΛ ։ൃ͢Δࡍʹൃੜͨ͠໰୊ʹର͢Δͻͱͭͷղܾࡦ ͳͥ(P͸ͭ͘ΒΕͨͷ͔

  14. • ϚϧνίΞϓϩηοαͷීวԽʹ൐͏ϓϩάϥϛϯάݴޠ ͷαϙʔτ͕গͳ͍ • WebϓϩάϥϛϯάϞσϧʹ͋ͬͨݴޠ͕ͳ͍ʁ • ਺ઍສߦͷίʔυ • ਺ඦɺ਺ઍ΋ͷ։ൃऀɺ·ͨ͸ͦͷ։ൃ؀ڥ •

    େن໛ͳίʔυʹΑΔϏϧυ࣌ؒͷ૿Ճ Google๊͕͑ͨ໰୊ ͳͥ(P͸ͭ͘ΒΕͨͷ͔
  15. • खଓ͖ܕͱඇಉظϓϩάϥϛϯά, LLݴޠͷΑ͏ͳ؆୯͞, ੩తܕ෇͚Λ ߹ΘͤͨσβΠϯ • ։ൃऀͷબ୒ࢶΛڱΊΔγϯϓϧͳจ๏, ॻ͖ํͷ౷Ұ • ϥΠϒϥϦɺϑΥʔϚολ,

    Ϧϯλ, ࣗಈੜ੒ͳͲπʔϧͷඪ४αϙʔτ Ͱॆ࣮ͤ͞Δ • γϯάϧόΠφϦ ͦͷղܾࡦͱͯ͠ͷGo ͳͥ(P͸ͭ͘ΒΕͨͷ͔
  16. • खଓ͖ܕͱඇಉظϓϩάϥϛϯά, LLݴޠͷΑ͏ͳ؆୯͞, ੩తܕ෇͚Λ ߹ΘͤͨσβΠϯ • ։ൃऀͷબ୒ࢶΛڱΊΔγϯϓϧͳจ๏, ॻ͖ํͷ౷Ұ • ϥΠϒϥϦɺϑΥʔϚολ,

    Ϧϯλ, ࣗಈੜ੒ͳͲπʔϧͷඪ४αϙʔτ Ͱॆ࣮ͤ͞Δ • γϯάϧόΠφϦ ͦͷղܾࡦͱͯ͠ͷGo ͳͥ(P͸ͭ͘ΒΕͨͷ͔ γεςϜͷεέʔϥϏϦςΟ ։ൃͷεέʔϥϏϦςΟ
  17. • GoϓϩάϥϜ͸GorutineͱݴΘΕΔܰྔεϨουͰಈ͘ • GoͷϥϯλΠϜ͸OSεϨου্ʹͦΕͧΕGroutineΛׂ Γ౰ͯͯεέδϡʔϧ͢Δ खଓ͖ͱඇಉظϓϩάϥϛϯάΛ߹ΘͤͨσβΠϯ ͳͥ(P͸ͭ͘ΒΕͨͷ͔ . ( 1

    ( ( running! waiting… ࢀߟਤ: GopherCon 2017: Kavya Joshi - Understanding Channels
  18. • ྫ͑͹ɺϊϯϒϩοΩϯάIOͳͲͷ଴ͪঢ়ଶ͕ൃੜ͢Δͱ ผͳGroutine͕ಈ͖ग़͢ खଓ͖ͱඇಉظϓϩάϥϛϯάΛ߹ΘͤͨσβΠϯ ͳͥ(P͸ͭ͘ΒΕͨͷ͔ . ( 1 ( (

    running! waiting… ࢀߟਤ: GopherCon 2017: Kavya Joshi - Understanding Channels
  19. • ྫ͑͹ɺϊϯϒϩοΩϯάIOͳͲͷ଴ͪঢ়ଶ͕ൃੜ͢Δͱ ผͳGroutine͕ಈ͖ग़͢ खଓ͖ͱඇಉظϓϩάϥϛϯάΛ߹ΘͤͨσβΠϯ ͳͥ(P͸ͭ͘ΒΕͨͷ͔ . ( 1 ( (

    running! waiting… ࢀߟਤ: GopherCon 2017: Kavya Joshi - Understanding Channels جຊతʹ։ൃऀ͕ͦ͜Λ ҙࣝ͠ͳͯ͘΋ Runtime͕উखʹඇಉظ ϓϩάϥϛϯάͯ͘͠ΕΔ!!!
  20. • map΍filterͳ͠ͷforจʹΑΔ൓෮ॲཧ • ྫ֎ػߏͳ͠ͷ໌ࣔతͳΤϥʔϋϯυϦϯά • goͱ͔͚ͩ͘ฒྻॲཧ͕Մೳ • interfaceʹΑΔந৅Խ, ίϯϙδοτͷ࣮ݱ •

    ։ൃऀ͕ϝϞϦ؅ཧͤͣʹ͢ΉGC͕͋Δ γϯϓϧͳจ๏ ͳͥ(P͸ͭ͘ΒΕͨͷ͔
  21. • map΍filterͳ͠ͷforจʹΑΔ൓෮ॲཧ • ྫ֎ػߏͳ͠ͷ໌ࣔతͳΤϥʔϋϯυϦϯά • goͱ͔͚ͩ͘ฒྻॲཧ͕Մೳ • interfaceʹΑΔந৅Խ, ίϯϙδοτͷ࣮ݱ •

    ։ൃऀ͕ϝϞϦ؅ཧͤͣʹ͢ΉGC͕͋Δ γϯϓϧͳจ๏ ͳͥ(P͸ͭ͘ΒΕͨͷ͔ ։ൃऀ͕ॻ͚Δදݱ͕େମܾ·ͬͯ͘Δ
  22. γεςϜͷεέʔϥϏϦΟ ͳͥ(P͸ͭ͘ΒΕͨͷ͔ Goͷ໨ඪ

  23. ݱ࣮తͳ໰୊Λղܾ͢ΔͨΊͷ߹ཧతͳݴޠ ͕͜͜޷͖ͦͷ̍ ͳͥ(P͸ͭ͘ΒΕͨͷ͔

  24. ๻ͨͪ͸ͲΜͳ࣌ʹඞཁ͔

  25. ͍ͭ(PͰॻ͘ͷ͔ ௕ظʹΘͨͬͯෳ਺ਓͷ։ൃऀͰ։ൃɺӡ༻͍ͯͨ͘͠Ίͷ େن໛ͳϓϩμΫτ, ༷ʑͳਓ͕৮ΔOSSͱͯ͠ • γϯάϧόΠφϦ • γϯϓϧͳจ๏

  26. ͍ͭ(PͰॻ͘ͷ͔ ඇಉظϓϩάϥϛϯάͱͯ͠ • ΞϓϦέʔγϣϯαʔόʔͷϓϩάϥϛϯά • IOͷଟ͍ϓϩάϥϜ

  27. ͕͜͜޷͖ͦͷ2 ͍ͭ(PͰॻ͘ͷ͔ ෳ਺ਓͰͷ νʔϜ։ൃ, αʔόʔαΠυϓϩάϥϛϯά ͕͠΍͍͢

  28. ͕͜͜޷͖ͦͷ2 ࣗ෼ͷ։ൃͱ͏·͍͜ͱϚον͍ͯͨ͠ ͍ͭ(PͰॻ͘ͷ͔ ෳ਺ਓͰͷ νʔϜ։ൃ, αʔόʔαΠυϓϩάϥϛϯά ͕͠΍͍͢

  29. GoΛͲ͏ֶΜͰ͍ͬͨΒ͍͍ʁ

  30. None
  31. None
  32. ޾ͤʹͳΕͨ

  33. ࣗ෼ͷྫ

  34. (PΛֶͿ GoΛಡΉձ @ktr_0731, @acomagu, @Yamashou0314 ͱ΍͍ͬͯΔ झຯͷ͋͏༑ୡɺಉ྅ͱٞ࿦͠ͳ͕Β΍Δͱḿͬͨ

  35. (PΛֶͿ GoProverbs,CodeReviewComments ͳͲͷߟ͑Λ΋ͱʹίʔυΛಡΉ

  36. (PΛֶͿ The bigger the interface, the weaker the abstraction. •

    ioύοέʔδ Errors are values. Don’t just check errors, handle them gracefully. Don’t panic. • ύοέʔδͷ֤ॴ ྫ
  37. (PΛֶͿ ͍ͬͺ͍ίʔυΛॻ͘

  38. (PΛֶͿ Go͸Go͔Βֶ΂Δ ͕͜͜޷͖ͦͷ3

  39. (PΛֶͿ ʮֶͿ্Ͱ͜Μͳ͜ͱΛ΍Δͱ͍͍ʯ ͳͲ͋ͬͨੋඇڭ͑ͯཉ͍͠Ͱ͢ʂ

  40. ޮ཰Խ͍ͨ͠

  41. ඪ४αϙʔτͷπʔϧɺϥΠϒϥϦ܈

  42. ੜ࢈ੑΛ͋͛ΔͨΊʹ goίϚϯυ • Ϗϧυ • ςετ • όΠφϦͷऔಘ • ґଘؔ܎ͷ؅ཧʢv1.11͔Β)

    • ϑΥʔϚολͳͲͷίʔυ੔ܗ • ܭଌπʔϧ • ίϯύΠϧ࣌ͷπʔϧ܈
  43. ੜ࢈ੑΛ͋͛ΔͨΊʹ gofmt, linter, vet, lsp • ඪ४ͷίϚϯυͰϑΥʔϚολɺϦϯλʔ͕ೖ͍ͬͯΔ • ։ൃऀ͸ͦΕʹै͏͚ͩྑ͍ •

    ࠷ۙɺLanguage Server ProtocolʹGoඪ४Ͱαϙʔτ!!!
  44. ੜ࢈ੑΛ͋͛ΔͨΊʹ ࣗಈੜ੒ godocίϚϯυ • ίʔυίϝϯτ͔Β υΩϡϝϯτΛࣗಈ ੜ੒

  45. ੜ࢈ੑΛ͋͛ΔͨΊʹ ࣗಈੜ੒ • go generate • Test: gotests • Mock:

    gomock, mockgen command • API: go-swagger, swaggo
  46. ੜ࢈ੑΛ͋͛ΔͨΊʹ go/ast Λ࢖ͬͨ੩తղੳ • GoͷͨΊͷGo

  47. ੜ࢈ੑΛ͋͛ΔͨΊʹ ࣗ෼ͷࣄྫ

  48. ੜ࢈ੑΛ͋͛ΔͨΊʹ [WIP] github.com/natumn/ddog cloud datastoreͷΤϯςΟςΟ΍ΠϯσοΫε༻ͷυΩϡϝ ϯτࣗಈੜ੒ͯ͘͠ΕΔCLIπʔϧ

  49. ։ൃͷεέʔϥϏϦΟ Goͷ໨ඪ ੜ࢈ੑΛ͋͛ΔͨΊʹ

  50. ੜ࢈ੑΛ͋͛ΔͨΊʹ ඪ४αϙʔτͰੜ࢈తͳπʔϧ͕ͨ͘͞Μ͋Δ ͕͜͜޷͖ͦͷ4

  51. ·ͱΊ • Go͸GoogleͰى͖ͨݱ࣮తͳ໰୊Λղܾ͢ΔͨΊʹੜ·Εͨݴ ޠ • ௕ظɺେن໛ͳϓϩμΫτʹదͨ͠ઃܭ • Go͸Go͔Βֶ΂Δ • ඪ४αϙʔτͰଟ͘ͷੜ࢈తͳπʔϧɺϥΠϒϥϦ͕ἧ͍ͬͯΔ

  52. Έͳ͞Μ͸GoͷͲΜͳ͜ͱ͕޷͖Ͱ͔͢?

  53. ͝੩ௌ͋Γ͕ͱ͏͍͟͝·ͨ͠ʂ