Slide 1

Slide 1 text

Bitkey Inc. Connect Product Noriki Takahashi ਓؒͷ௚ײʹରԠͤͨ͞ෳࡶ౓ͷܭଌπʔϧΛgo/ astͰ࣮૷ͯ͠Έͨ

Slide 2

Slide 2 text

Outline 1. ࣗݾ঺հ 2. ιʔείʔυͷෳࡶ౓ 3. Cognitive Complexityͱ͸ʁ 4. go/ast ͱ͸ʁ 5. ෳࡶ౓ܭଌπʔϧ࣮૷ 6. ֶͼͱิ଍ 7. ·ͱΊ 2 2

Slide 3

Slide 3 text

1. ࣗݾ঺հ 3 ● ∁ڮయੜ(Noriki Takahashi) ○ Twitter: @norinoriki0 ○ GitHub: nrnrk ● גࣜձࣾBitkey ○ bitkey platform ͱ͍͏”ΧΪ”ͷϓϥοτϑΥʔϜͷ։ൃ ● Go Ͱ։ൃ͍ͯ͠·͕͢ɺ go/ast ͸͜Ε·Ͱ৮ͬͨ͜ͱ͕͋Γ·ͤΜͰͨ͠ ● झຯ: ਺ֶɾ෺ཧֶ ○ zk-SNARKs ͷ਺ֶతͳଆ໘ΛטΈࡅ͘هࣄΛॻ͍ͨΓͯ͠·͢ ● #gocon Ͱײ૝ͳͲੋඇΑΖ͓͘͠Ͷ͕͍͠·͢ʂ

Slide 4

Slide 4 text

● Bitkey ͷ3ͭͷࣄۀυϝΠϯ ○ Homeʢ฻Β͠ʣ ○ Workspaceʢಇ͘ʣ ○ Experienceʢඇ೔ৗͷମݧʣ ● bitkey platform ○ 3ͭͷ hub ΞϓϦέʔγϣϯͷج൫ 1. ࣗݾ঺հ 4 ςΫϊϩδʔͷྗͰ͋ΒΏΔ΋ͷΛ ҆શͰ ศརͰ ؾ࣋ͪΑ͘ʮͭͳ͛Δʯ ͓͢͢Ί͍ͨ͠GoϥΠϒϥϦ౤ථड෇த!

Slide 5

Slide 5 text

● Bitkey ͷ3ͭͷࣄۀυϝΠϯ ○ Homeʢ฻Β͠ʣ ○ Workspaceʢಇ͘ʣ ○ Experienceʢඇ೔ৗͷମݧʣ ● bitkey platform ○ 3ͭͷ hub ΞϓϦέʔγϣϯͷج ൫ 1. ࣗݾ঺հ 5 ςΫϊϩδʔͷྗͰ͋ΒΏΔ΋ͷΛ ҆શͰ ศརͰ ؾ࣋ͪΑ͘ʮͭͳ͛Δʯ ͓͢͢Ί͍ͨ͠GoϥΠϒϥϦ౤ථड෇த! എܠͷ bitkey x Gopher͘ΜͷίϥϘʹ΋஫໨ʂ

Slide 6

Slide 6 text

ιʔείʔυͷෳࡶ౓ 6 6

Slide 7

Slide 7 text

ಥવͰ͕͢ Έͳ͞Μ 7 7 2. ιʔείʔυͷෳࡶ౓

Slide 8

Slide 8 text

ෳࡶͳιʔείʔυ͸޷͖Ͱ͔͢ʁ 8 8 2. ιʔείʔυͷෳࡶ౓

Slide 9

Slide 9 text

ෳࡶͳιʔείʔυ͸޷͖Ͱ͔͢ʁ 9 9 2. ιʔείʔυͷෳࡶ౓

Slide 10

Slide 10 text

ࢲ͸ͦΜͳʹ޷͖͡Ό͋Γ·ͤΜ 10 10 2. ιʔείʔυͷෳࡶ౓

Slide 11

Slide 11 text

ࢲ͸ͦΜͳʹ޷͖͡Ό͋Γ·ͤΜ 11 11 2. ιʔείʔυͷෳࡶ౓

Slide 12

Slide 12 text

Ͱ͖Δ͚ͩγϯϓϧʹͯ͠ อक͠΍͍ͨ͘͢͠ 12 12 2. ιʔείʔυͷෳࡶ౓

Slide 13

Slide 13 text

ෳࡶ͕͞ආ͚ΒΕͳ͍ͱ͖͸ ςετΛॏ఺తʹߦ͍͍ͨ 13 13 2. ιʔείʔυͷෳࡶ౓

Slide 14

Slide 14 text

͜ΕΒΛܧଓతʹ࣮ݱ͍ͯͨ͘͠Ίʹ 14 14 2. ιʔείʔυͷෳࡶ౓

Slide 15

Slide 15 text

ෳࡶ౓Λఆྔతʹද͍ͨ͠ 15 15 2. ιʔείʔυͷෳࡶ౓

Slide 16

Slide 16 text

ௐ΂ͨͱ͜Ζ 16 16 2. ιʔείʔυͷෳࡶ౓

Slide 17

Slide 17 text

ௐ΂ͨͱ͜Ζ 17 17 2. ιʔείʔυͷෳࡶ౓

Slide 18

Slide 18 text

ਓؒͷײ͡Δෳࡶ͞ʹରԠͨ͠ ࢦඪ͕͋ΔΒ͍͠ 18 18 2. ιʔείʔυͷෳࡶ౓

Slide 19

Slide 19 text

ͦΕ͕ 19 19 2. ιʔείʔυͷෳࡶ౓

Slide 20

Slide 20 text

Cognitive Complexity 20 20 2. ιʔείʔυͷෳࡶ౓

Slide 21

Slide 21 text

Cognitive Complexity 21 21 2. ιʔείʔυͷෳࡶ౓

Slide 22

Slide 22 text

Cognitive Complexity ͱ͸ 22 22

Slide 23

Slide 23 text

● Complexity (ෳࡶ౓) ͱ͸ 3. Cognitive Complexityͱ͸ʁ 23

Slide 24

Slide 24 text

● Complexity (ෳࡶ౓) ͱ͸ ○ ֊૚͕ਂ͍ͱෳࡶʁ 24 3. Cognitive Complexityͱ͸ʁ

Slide 25

Slide 25 text

● Complexity (ෳࡶ౓) ͱ͸ ○ ֊૚͕ਂ͍ͱෳࡶʁ ○ ෼ذ͕ଟ͍ͱෳࡶʁ 25 3. Cognitive Complexityͱ͸ʁ

Slide 26

Slide 26 text

● Complexity (ෳࡶ౓) ͱ͸ ○ ֊૚͕ਂ͍ͱෳࡶʁ ○ ෼ذ͕ଟ͍ͱෳࡶʁ ○ ίʔυྔ͕ଟ͍ͱෳࡶʁ 26 3. Cognitive Complexityͱ͸ʁ

Slide 27

Slide 27 text

● Complexity (ෳࡶ౓) ͱ͸ ○ ֊૚͕ਂ͍ͱෳࡶʁ ○ ෼ذ͕ଟ͍ͱෳࡶʁ ○ ίʔυྔ͕ଟ͍ͱෳࡶʁ ○ ߦ਺͕ଟ͍ͱෳࡶʁ 27 3. Cognitive Complexityͱ͸ʁ

Slide 28

Slide 28 text

● Complexity (ෳࡶ౓) ͱ͸ ○ ֊૚͕ਂ͍ͱෳࡶʁ ○ ෼ذ͕ଟ͍ͱෳࡶʁ ○ ίʔυྔ͕ଟ͍ͱෳࡶʁ ○ ߦ਺͕ଟ͍ͱෳࡶʁ → ஫໨͢ΔϙΠϯτʹΑͬͯࢦඪ͕ҟͳΔ 28 3. Cognitive Complexityͱ͸ʁ

Slide 29

Slide 29 text

● ༷ʑͳෳࡶ౓ͷࢦඪ ○ ॥؀తෳࡶ౓ (Cyclomatic Complexity) ■ ઢܗతʹಠཱͨ͠ܦ࿏ͷ਺ʹ஫໨ͨ͠ࢦඪ ■ (ͬ͘͟Γ͍͏ͱ) ܦ࿏ͷύλʔϯ͕ଟ͍ͱෳࡶͱ൑ఆ ○ Halstead ෳࡶ౓ ■ ௕͞΍“ޠኮ”ͷ਺ʹ஫໨ͨ͠ࢦඪ ■ (ͬ͘͟Γ͍͏ͱ) ௕͍΋ͷ΍දݱύλʔϯ͕ଟ͍ͱෳࡶͱ൑ఆ 29 3. Cognitive Complexityͱ͸ʁ

Slide 30

Slide 30 text

● ༷ʑͳෳࡶ౓ͷࢦඪ ○ ॥؀తෳࡶ౓ (Cyclomatic Complexity) ■ ઢܗతʹಠཱͨ͠ܦ࿏ͷ਺ʹ஫໨ͨ͠ࢦඪ ■ (ͬ͘͟Γ͍͏ͱ) ܦ࿏ͷύλʔϯ͕ଟ͍ͱෳࡶͱ൑ఆ ○ Halstead ෳࡶ౓ ■ ௕͞΍“ޠኮ”ͷ਺ʹ஫໨ͨ͠ࢦඪ ■ (ͬ͘͟Γ͍͏ͱ) ௕͍΋ͷ΍දݱύλʔϯ͕ଟ͍ͱෳࡶͱ൑ఆ 30 3. Cognitive Complexityͱ͸ʁ ༗໊ʂ਺ֶతͳϞσϧʹجͮ͘ʂ

Slide 31

Slide 31 text

● ೝ஌తෳࡶ౓ (Cognitive Complexity) ○ ਓؒͷ௚ײͱ͍ۙෳࡶ͞Λ໨ࢦͨ͠ࢦඪ ○ ίʔυͷઢܗͷྲྀΕΛཚ͢΋ͷʹ஫໨ ○ 2016೥ʹ஀ੜ ■ Cyclomatic Complexity: 1976೥ 31 White Paper: https://sonarsource.com/docs/CognitiveComplexity.pdf 3. Cognitive Complexityͱ͸ʁ

Slide 32

Slide 32 text

● ೝ஌తෳࡶ౓ (Cognitive Complexity) ○ ਓؒͷ௚ײͱ͍ۙෳࡶ͞Λ໨ࢦͨ͠ࢦඪ ○ ίʔυͷઢܗͷྲྀΕΛཚ͢΋ͷʹ஫໨ ○ 2016೥ʹ஀ੜ ■ Cyclomatic Complexity: 1976೥ 32 White Paper: https://sonarsource.com/docs/CognitiveComplexity.pdf 3. Cognitive Complexityͱ͸ʁ

Slide 33

Slide 33 text

“ਓؒͷ௚ײͱ͍ۙ” ͱ͸ʁ 33 33 3. Cognitive Complexityͱ͸ʁ

Slide 34

Slide 34 text

࣮ྫͰ֬ೝͯ͠ΈΔ 34 34 3. Cognitive Complexityͱ͸ʁ

Slide 35

Slide 35 text

͜͜Ͱ࣭໰Ͱ͢ 35 35 3. Cognitive Complexityͱ͸ʁ

Slide 36

Slide 36 text

࣍ͷ̎ͭ͸ͲͪΒ͕ෳࡶʁ 36 36 3. Cognitive Complexityͱ͸ʁ

Slide 37

Slide 37 text

37 37 ※ White Paper( https://sonarsource.com/docs/CognitiveComplexity.pdf ) ͷྫΛ Go ʹॻ͖௚ͨ͠΋ͷ Ͳ͕ͬͪෳࡶʁ 3. Cognitive Complexityͱ͸ʁ

Slide 38

Slide 38 text

Cyclomatic Complexity ͷ৔߹ 38 38 3. Cognitive Complexityͱ͸ʁ

Slide 39

Slide 39 text

39 39 ※ White Paper( https://sonarsource.com/docs/CognitiveComplexity.pdf ) ͷྫΛ Go ʹॻ͖௚ͨ͠΋ͷ 3. Cognitive Complexityͱ͸ʁ

Slide 40

Slide 40 text

40 40 ※ White Paper( https://sonarsource.com/docs/CognitiveComplexity.pdf ) ͷྫΛ Go ʹॻ͖௚ͨ͠΋ͷ ಉ͡ʂ 3. Cognitive Complexityͱ͸ʁ

Slide 41

Slide 41 text

Cognitive Complexity ͷ৔߹ 41 41 3. Cognitive Complexityͱ͸ʁ

Slide 42

Slide 42 text

42 42 ※ White Paper( https://sonarsource.com/docs/CognitiveComplexity.pdf ) ͷྫΛ Go ʹॻ͖௚ͨ͠΋ͷ 3. Cognitive Complexityͱ͸ʁ

Slide 43

Slide 43 text

43 43 ※ White Paper( https://sonarsource.com/docs/CognitiveComplexity.pdf ) ͷྫΛ Go ʹॻ͖௚ͨ͠΋ͷ େࠩʂ 3. Cognitive Complexityͱ͸ʁ

Slide 44

Slide 44 text

Cognitive Complexity ͍͍Ͷʂ 44 44 3. Cognitive Complexityͱ͸ʁ

Slide 45

Slide 45 text

45 ࢀߟ: White Pager (Appendix B) https://sonarsource.com/docs/CognitiveComplexity.pdf ● ෳࡶ౓ܭࢉϧʔϧ 3. Cognitive Complexityͱ͸ʁ

Slide 46

Slide 46 text

46 ࢀߟ: White Pager (Appendix B) https://sonarsource.com/docs/CognitiveComplexity.pdf ● ෳࡶ౓ܭࢉϧʔϧ 1. ҎԼͷཁૉ͕͋Ε͹ +1 for, switch, goto, if, else, if else, goto/break/continue 3. Cognitive Complexityͱ͸ʁ

Slide 47

Slide 47 text

47 ࢀߟ: White Pager (Appendix B) https://sonarsource.com/docs/CognitiveComplexity.pdf ● ෳࡶ౓ܭࢉϧʔϧ 1. ҎԼͷཁૉ͕͋Ε͹ +1 for, switch, goto, if, else, if else, goto/break/continue 1. ωετ࣌͸ɺ1. ʹ௥ՃͰ + (ωετͷਂ͞) 3. Cognitive Complexityͱ͸ʁ

Slide 48

Slide 48 text

48 ࢀߟ: White Pager (Appendix B) https://sonarsource.com/docs/CognitiveComplexity.pdf ● ෳࡶ౓ܭࢉϧʔϧ 1. ҎԼͷཁૉ͕͋Ε͹ +1 for, switch, goto, if, else, if else, goto/break/continue 1. ωετ࣌͸ɺ1. ʹ௥ՃͰ + (ωετͷਂ͞) 3. Cognitive Complexityͱ͸ʁ

Slide 49

Slide 49 text

● ෳࡶ౓ܭࢉϧʔϧ 1. ҎԼͷཁૉ͕͋Ε͹ +1 for, switch, goto, if, else, if else, goto/break/continue 1. ωετ࣌͸ɺ1. ʹ௥ՃͰ + (ωετͷਂ͞) 49 ࢀߟ: White Pager (Appendix B) https://sonarsource.com/docs/CognitiveComplexity.pdf for ΍ if Ͱෳࡶ౓͸૿Ճ 3. Cognitive Complexityͱ͸ʁ

Slide 50

Slide 50 text

● ෳࡶ౓ܭࢉϧʔϧ 1. ҎԼͷཁૉ͕͋Ε͹ +1 for, switch, goto, if, else, if else, goto/break/continue 1. ωετ࣌͸ɺ1. ʹ௥ՃͰ + (ωετͷਂ͞) 50 ࢀߟ: White Pager (Appendix B) https://sonarsource.com/docs/CognitiveComplexity.pdf 3. Cognitive Complexityͱ͸ʁ ωετͷਂ͕͞Ճࢉ஋ʹ

Slide 51

Slide 51 text

● ෳࡶ౓ܭࢉϧʔϧ 1. ҎԼͷཁૉ͕͋Ε͹ +1 for, switch, goto, if, else, if else, goto/break/continue 1. ωετ࣌͸ɺ1. ʹ௥ՃͰ + (ωετͷਂ͞) 51 ࢀߟ: White Pager (Appendix B) https://sonarsource.com/docs/CognitiveComplexity.pdf 3. Cognitive Complexityͱ͸ʁ early return ͸OK continue ͸NG

Slide 52

Slide 52 text

Go ͷϓϩάϥϜΛܭଌͯ͠Έ͍ͨʂ 52 52 3. Cognitive Complexityͱ͸ʁ

Slide 53

Slide 53 text

੩తղੳπʔϧΛ࡞ΔͨΊͷ ϥΠϒϥϦ͸ͨ͘͞Μ͋Δ 53 53 3. Cognitive Complexityͱ͸ʁ

Slide 54

Slide 54 text

golang.org/x/tools/go/analysis golang.org/x/tools/go/ast/inspector golang.org/x/tools/go/ast/astuil golang.org/x/tools/go/ssa … 54 54 3. Cognitive Complexityͱ͸ʁ

Slide 55

Slide 55 text

੩తղੳॳ৺ऀ͔Β͢Δͱ.. 55 55 3. Cognitive Complexityͱ͸ʁ

Slide 56

Slide 56 text

֓೦͕ଟͯ͘ཧղ͕େม͔΋... 56 56 3. Cognitive Complexityͱ͸ʁ

Slide 57

Slide 57 text

57 57 3. Cognitive Complexityͱ͸ʁ ֓೦͕ଟͯ͘ཧղ͕େม͔΋...

Slide 58

Slide 58 text

େݩʹ͋Δඪ४ͷ go/ast ͚ͩͰ΋े෼࡞ΕΔ 58 58 3. Cognitive Complexityͱ͸ʁ

Slide 59

Slide 59 text

੩తղੳͷ࠷ॳͷҰาͱͯ͠ جૅͱͯ͠ go/ast Λཧղ͍ͨ͠...! 59 59 3. Cognitive Complexityͱ͸ʁ

Slide 60

Slide 60 text

Cognitive Complexity ܭଌπʔϧ go/ast Ͱ࣮૷ͯ͠جຊΛཧղ͠Α͏ 60 60 3. Cognitive Complexityͱ͸ʁ

Slide 61

Slide 61 text

Cognitive Complexity ܭଌπʔϧ go/ast Ͱ࣮૷ͯ͠جຊΛཧղ͠Α͏ 61 61 3. Cognitive Complexityͱ͸ʁ

Slide 62

Slide 62 text

go/ast ͱ͸ʁ 62 62

Slide 63

Slide 63 text

● go/ast ͱ͸ ○ ߏจ໦Λදݱ͢ΔͨΊʹ࢖༻͞ΕΔܕ͕ೖͬͨύοέʔδ ○ linter Λ࡞Δͱ͖ͳͲʹར༻͞Ε͍ͯΔ 4. go/ast ͱ͸ʁ 63

Slide 64

Slide 64 text

● go/ast ͱ͸ ○ ߏจ໦Λදݱ͢ΔͨΊʹ࢖༻͞ΕΔܕ͕ೖͬͨύοέʔδ ○ linter Λ࡞Δͱ͖ͳͲʹར༻͞Ε͍ͯΔ ● AST(ந৅ߏจ໦)ͱ͸ ○ ιʔείʔυΛѻ͍΍͍͢Α͏ʹ໦ߏ଄ʹͨ͠΋ͷ ○ Abstract Syntax Tree ͷུ 4. go/ast ͱ͸ʁ 64

Slide 65

Slide 65 text

(ந৅)ߏจ໦ͬͯ݁ہͳΜͩ? 65 65 4. go/ast ͱ͸ʁ

Slide 66

Slide 66 text

ιʔείʔυͷίϯύΠϧ࣌ͷ ྲྀΕͰ֬ೝͯ͠ΈΔ 66 66 4. go/ast ͱ͸ʁ

Slide 67

Slide 67 text

67 67 ιʔείʔυ ࣮ߦϑΝΠϧ ίϯύΠϧ࣌ͷॲཧͷྲྀΕ 4. go/ast ͱ͸ʁ ίϯύΠϧ

Slide 68

Slide 68 text

68 68 ιʔείʔυ ߏจ໦ ࣮ߦϑΝΠϧ ࣈ۟ղੳ & ߏจղੳ ҙຯղੳ & ࠷దԽ ίϯύΠϧ࣌ͷॲཧͷྲྀΕ 4. go/ast ͱ͸ʁ

Slide 69

Slide 69 text

69 69 ιʔείʔυ ߏจ໦ ࣮ߦϑΝΠϧ func main() { result := `apple` + `pen` … } ࣈ۟ղੳ & ߏจղੳ ҙຯղੳ & ࠷దԽ ίϯύΠϧ࣌ͷॲཧͷྲྀΕ 4. go/ast ͱ͸ʁ

Slide 70

Slide 70 text

70 70 ιʔείʔυ ߏจ໦ ࣮ߦϑΝΠϧ func main() { result := `apple` + `pen` … } ࣈ۟ղੳ & ߏจղੳ ҙຯղੳ & ࠷దԽ ίϯύΠϧ࣌ͷॲཧͷྲྀΕ 4. go/ast ͱ͸ʁ apple pen +

Slide 71

Slide 71 text

71 71 ιʔείʔυ ߏจ໦ ࣮ߦϑΝΠϧ func main() { result := `apple` + `pen` … } ࣈ۟ղੳ & ߏจղੳ ҙຯղੳ & ࠷దԽ ίϯύΠϧ࣌ͷॲཧͷྲྀΕ 4. go/ast ͱ͸ʁ apple pen +

Slide 72

Slide 72 text

72 72 ιʔείʔυ ߏจ໦ ࣮ߦϑΝΠϧ func main() { result := `apple` + `pen` … } ࣈ۟ղੳ & ߏจղੳ ҙຯղੳ & ࠷దԽ ίϯύΠϧ࣌ͷॲཧͷྲྀΕ 4. go/ast ͱ͸ʁ apple pen +

Slide 73

Slide 73 text

73 73 ιʔείʔυ ߏจ໦ ࣮ߦϑΝΠϧ func main() { result := `apple` + `pen` … } ࣈ۟ղੳ & ߏจղੳ ҙຯղੳ & ࠷దԽ ίϯύΠϧ࣌ͷॲཧͷྲྀΕ ߏ଄Խ͞Ε͍ͯΔ͓͔͛Ͱ... ίʔυΛνΣοΫ͢Δॲཧ͕ॻ͖΍͍͢ (ྫ: ه๏ͷνΣοΫɺύοέʔδґଘͳͲ) AST = go/ast Ͱ͜ͷߏ଄Λར༻Ͱ͖ Δ 4. go/ast ͱ͸ʁ apple pen +

Slide 74

Slide 74 text

஫: ࣮͸Go ͷίϯύΠϥͰ͸ go/ast Λ࢖͍ͬͯͳ͍ → go/ast ͸੩తղੳπʔϧͳͲͰར༻͞Ε͍ͯΔ 74 74 4. go/ast ͱ͸ʁ

Slide 75

Slide 75 text

● go/ast Ͱදݱ͞ΕΔߏ଄ 75 4. go/ast ͱ͸ʁ

Slide 76

Slide 76 text

● go/ast Ͱදݱ͞ΕΔߏ଄ 76 Node Node Node Node Node Node 4. go/ast ͱ͸ʁ

Slide 77

Slide 77 text

● go/ast Ͱදݱ͞ΕΔߏ଄ 77 Node Node Node Node Node Node 4. go/ast ͱ͸ʁ ۩ମྫΛ go/ast ͷυΩϡϝϯτͰνΣοΫʂ

Slide 78

Slide 78 text

AssignStmt BinaryExpr BlockStmt BranchStmt CallExpr DeclStmt DeferStmt EmptyStmt ExprStmt ForStmt 78 78 4. go/ast ͱ͸ʁ FuncDecl GenDecl GoStmt IfStmt ImportSpec IncDecStmt IndexExpr KeyValueExpr LabeledStmt ParenExpr RangeStmt ReturnStmt SelectStmt SelectorExpr SendStmt SliceExpr StartExpr SwitchStmt TypeAssertExpr TypeSpec TypeSwitchStmt UnaryExpr ValueSpec ͳͲ

Slide 79

Slide 79 text

AssignStmt BinaryExpr BlockStmt BranchStmt CallExpr DeclStmt DeferStmt EmptyStmt ExprStmt ForStmt 79 79 4. go/ast ͱ͸ʁ FuncDecl GenDecl GoStmt IfStmt ImportSpec IncDecStmt IndexExpr KeyValueExpr LabeledStmt ParenExpr RangeStmt ReturnStmt SelectStmt SelectorExpr SendStmt SliceExpr StartExpr SwitchStmt TypeAssertExpr TypeSpec TypeSwitchStmt UnaryExpr ValueSpec ͳͲ େྔ...! Θ͚͕Θ͔Βͳ͍...

Slide 80

Slide 80 text

AssignStmt BinaryExpr BlockStmt BranchStmt CallExpr DeclStmt DeferStmt EmptyStmt ExprStmt ForStmt 80 80 4. go/ast ͱ͸ʁ FuncDecl GenDecl GoStmt IfStmt ImportSpec IncDecStmt IndexExpr KeyValueExpr LabeledStmt ParenExpr RangeStmt ReturnStmt SelectStmt SelectorExpr SendStmt SliceExpr StartExpr SwitchStmt TypeAssertExpr TypeSpec TypeSwitchStmt UnaryExpr ValueSpec ͳͲ ΜʁΑ͘ݟΔͱ຤ඌ͕ڞ௨͍ͯ͠Δ΍͕ͭ͋Δͳ

Slide 81

Slide 81 text

AssignStmt BinaryExpr BlockStmt BranchStmt CallExpr DeclStmt DeferStmt EmptyStmt ExprStmt ForStmt 81 81 4. go/ast ͱ͸ʁ FuncDecl GenDecl GoStmt IfStmt ImportSpec IncDecStmt IndexExpr KeyValueExpr LabeledStmt ParenExpr RangeStmt ReturnStmt SelectStmt SelectorExpr SendStmt SliceExpr StartExpr SwitchStmt TypeAssertExpr TypeSpec TypeSwitchStmt UnaryExpr ValueSpec ͳͲ

Slide 82

Slide 82 text

AssignStmt BinaryExpr BlockStmt BranchStmt CallExpr DeclStmt DeferStmt EmptyStmt ExprStmt ForStmt 82 82 4. go/ast ͱ͸ʁ FuncDecl GenDecl GoStmt IfStmt ImportSpec IncDecStmt IndexExpr KeyValueExpr LabeledStmt ParenExpr RangeStmt ReturnStmt SelectStmt SelectorExpr SendStmt SliceExpr StartExpr SwitchStmt TypeAssertExpr TypeSpec TypeSwitchStmt UnaryExpr ValueSpec ͳͲ υΩϡϝϯτ͸ABCॱʹฒΜͰ͍Δ͕ ߏ଄ମ໊ͷ຤ඌʹ஫໨ͯ͠෼ྨ͢ΔͱΘ͔Γ΍͍͢

Slide 83

Slide 83 text

Node ͷ෼ྨ ɾ Stmt : จ (Statement) ɾ Expr : ࣜ(Expression) ɾ Decl : એݴ(Declaration) ɾ Spec : εϖοΫ(Specification) ɾ Type : ܕ ɾ Lit : Ϧςϥϧ(Literal) etc… ● go/ast Ͱදݱ͞ΕΔߏ଄ 83 Node Node Node Node Node Node 4. go/ast ͱ͸ʁ

Slide 84

Slide 84 text

Node ͷ෼ྨ ɾ Stmt : จ (Statement) ɾ Expr : ࣜ(Expression) ɾ Decl : એݴ(Declaration) ɾ Spec : εϖοΫ(Specification) ɾ Type : ܕ ɾ Lit : Ϧςϥϧ(Literal) etc… ● go/ast Ͱදݱ͞ΕΔߏ଄ 84 Node Node Node Node Node Node 4. go/ast ͱ͸ʁ ιʔείʔυ্΋࣮͸ interface ͕ ͪΌΜͱఆٛ͞Ε͍ͯΔ

Slide 85

Slide 85 text

࣮ྫͰνΣοΫʂ 85 85 4. go/ast ͱ͸ʁ

Slide 86

Slide 86 text

4. go/ast ͱ͸ʁ gopher.go

Slide 87

Slide 87 text

4. go/ast ͱ͸ʁ gopher.go main.go : “gopher.go” ͷ AST Λग़ྗ͢Δ

Slide 88

Slide 88 text

4. go/ast ͱ͸ʁ gopher.go main.go : “gopher.go” ͷ AST Λग़ྗ͢Δ AST ʹม׵ AST Λग़ྗ

Slide 89

Slide 89 text

File GenDecl FuncDecl Ident BlockStm t CallExpr ImportSpec SelectorExpr BasicLit Ident FuncType FieldList BasicLit Ident Ident 4. go/ast ͱ͸ʁ gopher.go

Slide 90

Slide 90 text

File GenDecl FuncDecl Ident BlockStm t CallExpr ImportSpec SelectorExpr BasicLit Ident FuncType FieldList BasicLit Ident Ident main import (શମ) import (1ͭ) “fmt” () (Ҿ਺ͳ͠) “gopher ” func {} fmt Printl n “Gopher! !” ( ) . 4. go/ast ͱ͸ʁ gopher.go

Slide 91

Slide 91 text

File GenDecl FuncDecl Ident BlockStm t CallExpr ImportSpec SelectorExpr BasicLit Ident FuncType FieldList BasicLit Ident Ident main import (શମ) import (1ͭ) “fmt” () (Ҿ਺ͳ͠) “gopher ” func {} fmt Printl n “Gopher! !” ( ) File ͕ϧʔτʂ . 4. go/ast ͱ͸ʁ gopher.go

Slide 92

Slide 92 text

File GenDecl FuncDecl Ident BlockStm t CallExpr ImportSpec SelectorExpr BasicLit Ident FuncType FieldList BasicLit Ident Ident main import (શମ) import (1ͭ) “fmt” () (Ҿ਺ͳ͠) “gopher ” func {} . fmt Printl n “Gopher! !” ( ) File ͕ϧʔτʂ 4. go/ast ͱ͸ʁ gopher.go

Slide 93

Slide 93 text

File GenDecl FuncDecl Ident BlockStm t CallExpr ImportSpec SelectorExpr BasicLit Ident FuncType FieldList BasicLit Ident Ident main import (શମ) import (1ͭ) “fmt” () (Ҿ਺ͳ͠) “gopher ” func {} . fmt Printl n “Gopher! !” ( ) File ͕ϧʔτʂ 4. go/ast ͱ͸ʁ gopher.go

Slide 94

Slide 94 text

File GenDecl FuncDecl Ident BlockStm t CallExpr ImportSpec SelectorExpr BasicLit Ident FuncType FieldList BasicLit Ident Ident main import (શମ) import (1ͭ) “fmt” () (Ҿ਺ͳ͠) “gopher ” func {} . fmt Printl n “Gopher! !” ( ) File ͕ϧʔτʂ 4. go/ast ͱ͸ʁ gopher.go

Slide 95

Slide 95 text

File GenDecl FuncDecl Ident BlockStm t CallExpr ImportSpec SelectorExpr BasicLit Ident FuncType FieldList BasicLit Ident Ident main import (શମ) import (1ͭ) “fmt” () (Ҿ਺ͳ͠) “gopher ” func {} . fmt Printl n “Gopher! !” ( ) File ͕ϧʔτʂ 4. go/ast ͱ͸ʁ gopher.go

Slide 96

Slide 96 text

ෳࡶ౓ܭଌπʔϧ࣮૷ 96 96

Slide 97

Slide 97 text

● ෳࡶ౓ܭଌπʔϧ ○ ιʔείʔυ͔Β֤ؔ਺͝ͱͷ Cognitive Complexity Λܭࢉ͢Δ 5. ෳࡶ౓ܭଌπʔϧ࣮૷ 97

Slide 98

Slide 98 text

● ෳࡶ౓ܭଌπʔϧ ○ ιʔείʔυ͔Β֤ؔ਺͝ͱͷ Cognitive Complexity Λܭࢉ͢Δ ● શମͷߏ଄ 1. ιʔείʔυ͔ΒASTΛੜ੒ 2. AST͔Βؔ਺ͷϊʔυͷΈநग़ 3. ֤ؔ਺಺ͷෳࡶ౓Λܭࢉ 98 5. ෳࡶ౓ܭଌπʔϧ࣮૷

Slide 99

Slide 99 text

ᶃ ιʔείʔυ͔ΒASTΛੜ੒ 99 99 5. ෳࡶ౓ܭଌπʔϧ࣮૷

Slide 100

Slide 100 text

ᶃ ιʔείʔυ͔ΒASTΛੜ੒ 100 100 5. ෳࡶ౓ܭଌπʔϧ࣮૷

Slide 101

Slide 101 text

ᶃ ιʔείʔυ͔ΒASTΛੜ੒ 101 101 ϧʔτʹͳΔ Node (File) ͕औಘͰ͖Δ ଞͷNode͸͔͜͜ΒͨͲΔ͜ͱ͕Ͱ͖Δ 5. ෳࡶ౓ܭଌπʔϧ࣮૷

Slide 102

Slide 102 text

ᶄ AST͔Βؔ਺ͷϊʔυͷΈநग़ 102 102 5. ෳࡶ౓ܭଌπʔϧ࣮૷

Slide 103

Slide 103 text

ᶄ AST͔Βؔ਺ͷϊʔυͷΈநग़ 103 103 ᶃ ͷ File (Node) 5. ෳࡶ౓ܭଌπʔϧ࣮૷

Slide 104

Slide 104 text

ᶄ AST͔Βؔ਺ͷϊʔυͷΈநग़ 104 104 ίʔυͷதͷؔ਺ͷΈΛऔΓग़͢ → ᶅ Ͱؔ਺ຖʹॲཧ ᶃ ͷ File (Node) 5. ෳࡶ౓ܭଌπʔϧ࣮૷

Slide 105

Slide 105 text

ᶅ ֤ؔ਺಺ͷෳࡶ౓Λܭࢉ 105 105 5. ෳࡶ౓ܭଌπʔϧ࣮૷

Slide 106

Slide 106 text

3-1. ෳࡶ౓ͷܭࢉϧʔϧ࠶֬ೝ 106 106 5. ෳࡶ౓ܭଌπʔϧ࣮૷

Slide 107

Slide 107 text

● ෳࡶ౓ܭࢉϧʔϧ(࠶ܝ) 1. ҎԼͷཁૉ͕͋Ε͹ +1 for, switch, goto, if, else, if else, goto/break/continue 1. ωετ࣌͸ɺ1. ʹ௥ՃͰ + (ωετͷਂ͞) 107 ࢀߟ: White Pager (Appendix B) https://sonarsource.com/docs/CognitiveComplexity.pdf 5. ෳࡶ౓ܭଌπʔϧ࣮૷

Slide 108

Slide 108 text

3-2. ॲཧͷશମ૾ 108 108 5. ෳࡶ౓ܭଌπʔϧ࣮૷

Slide 109

Slide 109 text

ᶅ ֤ؔ਺಺ͷෳࡶ౓Λܭࢉ ؔ਺ຖʹ Visitor Ͱ֤ϊʔυΛ૸ࠪͤ͞Δ 109 109 FuncDecl CallExpr ForStmt ReturnStmt IfStmt BranchStmt ※ ؆ུ൛AST 5. ෳࡶ౓ܭଌπʔϧ࣮૷

Slide 110

Slide 110 text

ᶅ ֤ؔ਺಺ͷෳࡶ౓Λܭࢉ ؔ਺ຖʹ Visitor Ͱ֤ϊʔυΛ૸ࠪͤ͞Δ 110 110 FuncDecl CallExpr ForStmt ReturnStmt IfStmt BranchStmt ※ ؆ུ൛AST for if continue 5. ෳࡶ౓ܭଌπʔϧ࣮૷

Slide 111

Slide 111 text

ᶅ ֤ؔ਺಺ͷෳࡶ౓Λܭࢉ ؔ਺ຖʹ Visitor Ͱ֤ϊʔυΛ૸ࠪͤ͞Δ 111 111 FuncDecl CallExpr ForStmt ReturnStmt IfStmt BranchStmt ※ ؆ུ൛AST for if continue (+1) 5. ෳࡶ౓ܭଌπʔϧ࣮૷

Slide 112

Slide 112 text

ᶅ ֤ؔ਺಺ͷෳࡶ౓Λܭࢉ ؔ਺ຖʹ Visitor Ͱ֤ϊʔυΛ૸ࠪͤ͞Δ 112 112 FuncDecl CallExpr ForStmt ReturnStmt IfStmt BranchStmt ※ ؆ུ൛AST for if continue (+1) (+2) 5. ෳࡶ౓ܭଌπʔϧ࣮૷

Slide 113

Slide 113 text

ᶅ ֤ؔ਺಺ͷෳࡶ౓Λܭࢉ ؔ਺ຖʹ Visitor Ͱ֤ϊʔυΛ૸ࠪͤ͞Δ 113 113 FuncDecl CallExpr ForStmt ReturnStmt IfStmt BranchStmt ※ ؆ུ൛AST for if continue (+1) (+2) (+1) 5. ෳࡶ౓ܭଌπʔϧ࣮૷

Slide 114

Slide 114 text

ᶅ ֤ؔ਺಺ͷෳࡶ౓Λܭࢉ ؔ਺ຖʹ Visitor Ͱ֤ϊʔυΛ૸ࠪͤ͞Δ 114 114 FuncDecl CallExpr ForStmt ReturnStmt IfStmt BranchStmt ※ ؆ུ൛AST for if continue (+1) (+2) (+1) ෳࡶ౓: 4 5. ෳࡶ౓ܭଌπʔϧ࣮૷

Slide 115

Slide 115 text

ᶅ ֤ؔ਺಺ͷෳࡶ౓Λܭࢉ ؔ਺ຖʹ Visitor Ͱ֤ϊʔυΛ૸ࠪͤ͞Δ 115 115 FuncDecl CallExpr ForStmt ReturnStmt IfStmt BranchStmt ※ ؆ུ൛AST for if continue (+1) (+2) (+1) ෳࡶ౓: 4 5. ෳࡶ౓ܭଌπʔϧ࣮૷ ࣮૷ͷࢀߟ: https://github.com/fzipp/gocyclo, https://github.com/uudashr/gocognit

Slide 116

Slide 116 text

ᶅ ֤ؔ਺಺ͷෳࡶ౓Λܭࢉ ؔ਺ຖʹ Visitor Ͱ֤ϊʔυΛ૸ࠪͤ͞Δ 116 116 FuncDecl CallExpr ForStmt ReturnStmt IfStmt BranchStmt ※ ؆ུ൛AST for if continue (+1) (+2) (+1) ෳࡶ౓: 4 ෳࡶ౓Λอ࣋ 5. ෳࡶ౓ܭଌπʔϧ࣮૷ ࣮૷ͷࢀߟ: https://github.com/fzipp/gocyclo, https://github.com/uudashr/gocognit

Slide 117

Slide 117 text

ᶅ ֤ؔ਺಺ͷෳࡶ౓Λܭࢉ ؔ਺ຖʹ Visitor Ͱ֤ϊʔυΛ૸ࠪͤ͞Δ 117 117 FuncDecl CallExpr ForStmt ReturnStmt IfStmt BranchStmt ※ ؆ུ൛AST for if continue (+1) (+2) (+1) ෳࡶ౓: 4 ωετͷਂ͞Λอ࣋ 5. ෳࡶ౓ܭଌπʔϧ࣮૷ ࣮૷ͷࢀߟ: https://github.com/fzipp/gocyclo, https://github.com/uudashr/gocognit

Slide 118

Slide 118 text

ᶅ ֤ؔ਺಺ͷෳࡶ౓Λܭࢉ ؔ਺ຖʹ Visitor Ͱ֤ϊʔυΛ૸ࠪͤ͞Δ 118 118 FuncDecl CallExpr ForStmt ReturnStmt IfStmt BranchStmt ※ ؆ུ൛AST for if continue (+1) (+2) (+1) ෳࡶ౓: 4 ࣮૷ͷࢀߟ: https://github.com/fzipp/gocyclo, https://github.com/uudashr/gocognit ܭࢉϧʔϧͷΤοδέʔε΁ͷରԠ (ࣗݾ࠶ؼͷݕ஌ ΍ʮelse if ͱ ifʯͷ۠ผ ) ※ ݸผͷ࿩ͳͷͰؾʹ͠ͳͯ͘OK 5. ෳࡶ౓ܭଌπʔϧ࣮૷

Slide 119

Slide 119 text

֤ϊʔυ΁ͷ૸ࠪॲཧͬͯͲ͏͢Ε͹ 119 119 5. ෳࡶ౓ܭଌπʔϧ࣮૷

Slide 120

Slide 120 text

go/ast ʹؔ਺͕༻ҙ͞Ε͍ͯΔ 120 120 5. ෳࡶ౓ܭଌπʔϧ࣮૷

Slide 121

Slide 121 text

3-3. ૸ࠪͷ࣮૷ 121 121 5. ෳࡶ౓ܭଌπʔϧ࣮૷

Slide 122

Slide 122 text

● ૸ࠪͷ࣮૷ 122 122 ast.Walk ࢦఆͨ͠ node ҎԼΛ visitor Ͱ૸ࠪ ast.Visitor ࢦఆ͞Εͨ node ΛVisitͰ૸ࠪ 5. ෳࡶ౓ܭଌπʔϧ࣮૷

Slide 123

Slide 123 text

● ૸ࠪͷ࣮૷ 123 123 ast.Walk ࢦఆͨ͠ node ҎԼΛ visitor Ͱ૸ࠪ ast.Visitor ࢦఆ͞Εͨ node ΛVisitͰ૸ࠪ Visit ͷ࣮૷ྫ 5. ෳࡶ౓ܭଌπʔϧ࣮૷

Slide 124

Slide 124 text

● ૸ࠪͷ࣮૷ 124 124 ast.Walk ࢦఆͨ͠ node ҎԼΛ visitor Ͱ૸ࠪ ast.Visitor ࢦఆ͞Εͨ node ΛVisitͰ૸ࠪ }Node͝ͱʹ ෼ذͯ͠ॲཧ Visit ͷ࣮૷ྫ 5. ෳࡶ౓ܭଌπʔϧ࣮૷

Slide 125

Slide 125 text

● ૸ࠪͷ࣮૷ 125 125 ast.Walk ࢦఆͨ͠ node ҎԼΛ visitor Ͱ૸ࠪ ast.Visitor ࢦఆ͞Εͨ node ΛVisitͰ૸ࠪ }Node͝ͱʹ ෼ذͯ͠ॲཧ Visit ͷ࣮૷ྫ ͜͜ͷத਎͸ͲΜͳײ͡ʁ 5. ෳࡶ౓ܭଌπʔϧ࣮૷

Slide 126

Slide 126 text

● ૸ࠪͷ࣮૷ ྫ: ForStmt ༻ͷॲཧ 126 126 5. ෳࡶ౓ܭଌπʔϧ࣮૷

Slide 127

Slide 127 text

1 + (ωετͷਂ͞) ͚ͩෳࡶ౓Λ௥Ճ ● ૸ࠪͷ࣮૷ ྫ: ForStmt ༻ͷॲཧ 127 127 5. ෳࡶ౓ܭଌπʔϧ࣮૷

Slide 128

Slide 128 text

● ૸ࠪͷ࣮૷ ྫ: ForStmt ༻ͷॲཧ ॳظԽɾ৚݅ɾมԽʹཁૉ͕ ͋Ε͹ͦͪΒΛ૸ࠪ (ਂ͞༏ઌ) 128 128 5. ෳࡶ౓ܭଌπʔϧ࣮૷

Slide 129

Slide 129 text

● ૸ࠪͷ࣮૷ ྫ: ForStmt ༻ͷॲཧ ωετΛ1ͭਂͯ͘͠ຊମॲཧ ↓ ऴΘͬͨΒωετΛ1ͭ໭͢ 129 129 5. ෳࡶ౓ܭଌπʔϧ࣮૷

Slide 130

Slide 130 text

ᶅ ֤ؔ਺಺ͷෳࡶ౓Λܭࢉ ׬ྃʂ 130 130 5. ෳࡶ౓ܭଌπʔϧ࣮૷

Slide 131

Slide 131 text

ᶃʙᶅΛ૊Έ߹ΘͤΔ 131 131 5. ෳࡶ౓ܭଌπʔϧ࣮૷

Slide 132

Slide 132 text

132 132 5. ෳࡶ౓ܭଌπʔϧ࣮૷

Slide 133

Slide 133 text

133 133 5. ෳࡶ౓ܭଌπʔϧ࣮૷

Slide 134

Slide 134 text

134 134 5. ෳࡶ౓ܭଌπʔϧ࣮૷

Slide 135

Slide 135 text

135 135 5. ෳࡶ౓ܭଌπʔϧ࣮૷

Slide 136

Slide 136 text

׬੒඼͸ͪ͜Β https://github.com/nrnrk/gocognito 136 136 5. ෳࡶ౓ܭଌπʔϧ࣮૷

Slide 137

Slide 137 text

ײ૝ 137 137 5. ෳࡶ౓ܭଌπʔϧ࣮૷

Slide 138

Slide 138 text

go/ast ศརʂָ͍͠ʂ 138 138 5. ෳࡶ౓ܭଌπʔϧ࣮૷

Slide 139

Slide 139 text

go/ast ศརʂָ͍͠ʂ 139 139 5. ෳࡶ౓ܭଌπʔϧ࣮૷

Slide 140

Slide 140 text

ֶͼͱิ଍ 140 140

Slide 141

Slide 141 text

● ֶͼ ○ go/ast ͷߏ଄ମΛཧղ͢Δͱ͖ͷίπ ■ Stmt(จ) ͳͲͰ෼ྨ͢ΔͱΘ͔Γ΍͍͢ ■ Goݴޠ࢓༷ͷϖʔδͰݕࡧͯ͠Θ͔Δ͜ͱ΋ʂ ■ tenntenn ͞Μͷهࣄ܈͸੩తղੳͷ޿͍ൣғΛղઆͯ͘͠Ε͍ͯΔ ○ ੩తղੳπʔϧͷࣗ࡞ʹΑͬͯ go/ast ͱ Goݴޠͷཧղ͕ਂ·ͬͨ ■ → ʮ੩తղੳπʔϧ͍ͭͰ΋࡞ΕΔͥʂʯͱੵۃతͳؾ࣋ͪʹ 6. ֶͼͱิ଍ 141

Slide 142

Slide 142 text

● ิ଍ ○ golang.org/x/tools/go/analysis Λ࢖͏ͱ΋ͬͱศརʂ ■ ࡞ͬͨπʔϧΛ؆୯ʹఏڙͰ͖Δ(Analyzer) ■ ͢Ͱʹ͋ΔπʔϧΛ؆୯ʹ૊Έ߹ΘͤΒΕΔ (FuncDecl ͷϑΟϧλ) ■ ςετ͕؆୯ʹ͔͚Δ(analysistest) ○ ͦͷଞͷؔ࿈ϥΠϒϥϦ ■ golang.org/x/tools/go/ssa ● ม਺ͷ࠶୅ೖͳͲΛ௥͍͔͚Δඞཁ͕͋Δͱ͖ͳͲ ■ golang.org/x/tools/go/ast/astutil ● AST ࣗମʹมߋΛՃ͑Δͱ͖ͳͲ 142 6. ֶͼͱิ଍

Slide 143

Slide 143 text

● ิ଍ ○ golang.org/x/tools/go/analysis Λ࢖͏ͱ΋ͬͱศརʂ ■ ࡞ͬͨπʔϧΛ؆୯ʹఏڙͰ͖Δ(Analyzer) ■ ͢Ͱʹ͋ΔπʔϧΛ؆୯ʹ૊Έ߹ΘͤΒΕΔ (FuncDecl ͷϑΟϧλ) ■ ςετ͕؆୯ʹ͔͚Δ(analysistest) ○ ͦͷଞͷؔ࿈ϥΠϒϥϦ ■ golang.org/x/tools/go/ssa ● ม਺ͷ࠶୅ೖͳͲΛ௥͍͔͚Δඞཁ͕͋Δͱ͖ͳͲ ■ golang.org/x/tools/go/ast/astutil ● AST ࣗମʹมߋΛՃ͑Δͱ͖ͳͲ 143 6. ֶͼͱิ଍

Slide 144

Slide 144 text

144 6. ֶͼͱิ଍ golang.org/x/tools/go/analysis/analysistest ͷྫ → ςετର৅ͷؔ਺Λ testdata/src/a/a.go ʹஔ͍ͯɺ “// want “ ίϝϯτΛॻ͚ͩ͘Ͱྑ͍ʂ testdata/src/a/a.go

Slide 145

Slide 145 text

145 6. ֶͼͱิ଍ golang.org/x/tools/go/analysis/analysistest ͷྫ → ςετର৅ͷؔ਺Λ testdata/src/a/a.go ʹஔ͍ͯɺ “// want “ ίϝϯτΛॻ͚ͩ͘Ͱྑ͍ʂ testdata/src/a/a.go

Slide 146

Slide 146 text

·ͱΊ 146 146

Slide 147

Slide 147 text

● ·ͱΊ ○ Cognitive Complexity ͸ɺਓؒʹͱͬͯͷෳࡶ౓Λද͢ࢦඪ ○ go/ast Λ࢖͏͜ͱͰෳࡶ౓ͷܭଌπʔϧͳͲͷ੩తղੳπʔϧΛ؆୯ʹ࣮ ૷͢Δ͜ͱ͕Ͱ͖Δ ■ golang.org/x/tools/go/analysis ͳͲ΋ศར ○ go/ast ָ͔ͬͨ͠ʂ࢖ͬͨ͜ͱ͕ͳ͍ਓ͸ੋඇ࢖ͬͯΈΑ͏ʂ 147 7. ·ͱΊ ͓͢͢Ί͍ͨ͠GoϥΠϒϥϦ౤ථड෇த!