Upgrade to Pro — share decks privately, control downloads, hide ads and more …

20170605_make_and_learn_minimum_golint.pdf

5ade34f8bdf1b55c4ff82c11cf23cf42?s=47 Masayuki Morita
June 05, 2017
26

 20170605_make_and_learn_minimum_golint.pdf

5ade34f8bdf1b55c4ff82c11cf23cf42?s=128

Masayuki Morita

June 05, 2017
Tweet

Transcript

  1. ࡞ֶͬͯͿ ϛχϚϜgolint @minamijoyo 2017/06/05

  2. ࣗݾ঺հ • ৿ా ਅ೭ (Masayuki Morita) • Twitter/GitHub: @minamijoyo •

    CrowdWorks Inc. • Πϯϑϥ୲౰ • ͍͍ͩͨAWS/Terraform/Dockerͱ͔͍ͬͯ͡Δ
  3. Πϯϑϥ୲౰͕ࠓ͙͢ GoΛֶͿ΂͖3ͭͷཧ༝ 1. Go੡ϛυϧ΢ΣΞ΍CLIπʔϧ͕૿͖͑ͯͨɻ 2. bashεΫϦϓτͭΒ͍ɻGo͸ॻָ͍͍ͯͯ͠ɻ 3. Gopher͘Μ͕͔Θ͍͍ɻ The Go

    gopher was designed by Renée French.
  4. ࠓ೔ͷςʔϚ: ࠷ۙɺgolintͰ༡ΜͰΈͨ࿩

  5. golintͯ͠·͔͢ʁ

  6. golint • ެࣜͷLinter • GoͬΆ͘ͳ͍ίʔσΟϯάελΠϧΛࢦఠ $ go get -u github.com/golang/lint/golint

  7. $ golint main.go main.go:6:2: var instanceId should be instanceID

  8. Ͳ͏΍ͬͯ൑ఆͯ͠Δͷ͔ʁ

  9. ͨͩͷࣙॻͩͬͨ (※࣮ࡍʹ͸୯ޠͷ్தͷ΋ͷ΋ݕग़͍ͯ͠ΔͷͰগ͠ෳࡶʣ https://github.com/golang/lint/blob/master/lint.go

  10. ͔͠͠ golintͷίʔυΛͨͩோΊͯͯ΋ ੩తղੳ͕ ॳ৺ऀʹΑ͘Θ͔ΒΜͷͰ͢

  11. ͦ͏ͩ golint࡞Ζ͏

  12. ϓϩάϥϛϯάֶशͷجຊ: ·ͶΔ

  13. ࡞ֶͬͯͿ golint

  14. ϛχϚϜͳཁ݅ • ػೳɿಛఆͷม਺໊Λ୳͢ • ೖྗɿ1ϑΝΠϧͷΈҾ਺ͰϑΝΠϧ໊Λ౉͢ • ग़ྗɿϚονͨ͠ϑΝΠϧ໊:ߦ਺:ΧϥϜΛදࣔ

  15. 80ߦ͙Β͍Ͱॻ͚ͨ

  16. ←ඪ४ͷgoύοέʔδΛ࢖͏ ↓Ҿ਺ͰೖྗϑΝΠϧ໊Λ΋Β͏

  17. ↓ϑΝΠϧΛύʔεͯ͠ASTΛऔಘ

  18. ↑ࠨลͷࣝผࢠΛऔΓग़ͯ͠νΣοΫ ↑ASTΛ࠶ؼతʹ୳ࡧ ←ม਺୅ೖࣜΛ୳͢visitor

  19. ↑ม਺໊ʹϚονͨ͠ΒҐஔΛग़ྗ ←୳͢ม਺໊ͷఆٛ

  20. ม਺wallyΛ୳ͤ

  21. wally + golint = wallint

  22. $ wallint data/wally.go data/wally.go:6:2: wally was found

  23. ͔ͤͬ͘ͳͷͰ ΤσΟλʹ૊ΈࠐΜͰΈͨ

  24. ม਺wallyΛ୳ͤ

  25. ҰॠͰӅΕͨม਺wallyΛݕग़

  26. ·ͱΊ • ϓϩάϥϛϯάͷجຊ͸·ͶΔ͜ͱ • ࡞ֶͬͯͿͱཧղ͕ਂ·Δ • આ໌ʹ࢖ͬͨίʔυˣ • https://github.com/minamijoyo/wallint