Pro Yearly is on sale from $80 to $50! »

go generate と go/ast のざっくりとした話

go generate と go/ast のざっくりとした話

go generateとgo/astの話をざっくりとします。

Ebac3bbb6c39bee8da4d2772f704164a?s=128

Masashi Salvador Mitsuzawa

October 06, 2016
Tweet

Transcript

  1. HPHFOFSBUF"45΀5*14 .BTBTIJ4BMWBEPS.JUTV[BXB!FVSFLB

  2. BCPVU8IP*BN .BTBTIJ4BMWBEPS.JUTV[BXB UXJUUFS!.BTBTIJ4BMWBEPS 4FSWFSTJEFFOHJOFFS!QBJSTEJWJTJPO ܦྺ ݄%F/"ೖࣾ ݄Τ΢ϨΧೖࣾ 1)1(P%BUB.JHSBUJPOQSPEVDU։ൃ ޷͖ͳݴޠ 3VCZ

    (PMBOH +BWBTDSJQU )BTLFMM ݩʑͷઐ໳ ܭࢉ࿦తਆܦՊֶʢ೴ͷۭؒهԱʹؔ͢Δ਺ཧϞσϧͷݚڀʣ ػցֶशʢಛʹڧԽֶशʣ झຯ ஡ಓࣗసंΞ΢τυΞόοΫύοΧʔ
 ΧϨʔ৯͏ͨΊʹੜ͖ͯΔ
  3. (P΀ṽ͟ͼᖃ 4JNQMJDJUZ EPU(P3PC1JLF4JNQMJDJUZJT$PNQMJDBUFE 5IFTUBUFPG(P

  4. HPHFOFSBUF HP͝ΛႳ᥍ 5IFHPDPNNBOEIBTBOFXTVCDPNNBOE HPHFOFSBUF  UPBVUPNBUFUIFSVOOJOHPGUPPMTUPHFOFSBUFTPVSDFDPEFCFGPSFDPNQJMBUJPO
 θϸϖΩϰ᧸ͽς⑲ξθ⑲ώΤᓺᕧͫΝͱΓ΀ω⑲ϰ΀࣮ḝΤᥦხặͫΝ -FUUIFNBDIJOFEPUIFXPSL 3PC1JLF (FOFSBUJOHDPEF

    5IF(P#MPH 3FMFBTF/PUFΚΜ (P΀ς⑲ξθ⑲ώ΀θϦϸύͽ ᑿ͖ፖ Τᔉ͟
  5. 4USJOHFS΀ᆚď໋ᙚϛϲεΚΜĐ ᨷ਺ᨷᤅ የᥙᅾ͹ᶡᙎͩͱ͖ ͥΞΤბႷᗌ͹ᔉ͡΀΁ͶΛ͖ TUSJOHFSθϣϸώ͹ᥦხᓺᕧͫΝ

  6. 4USJOHFS΀ᆚď໋ᙚϛϲεΚΜĐ QJMMHP QJMM@TUSJOHHP ᥦხᓺᕧͧΞͱθ⑲ώĐ ᥦხᓺᕧ΁͖͖͞ 5IFSFTOPRVFTUJPOUIFHFOFSBUFENFUIPEJTVHMZ 5IBUT0, UIPVHI CFDBVTFIVNBOTEPOUOFFEUPXPSLPOJU 3PC1JLF

    (FOFSBUJOHDPEF 5IF(P#MPH  ຖỹTUSJOHFSθϣϸώΤຒ͡Ħ.BLFGJMFᄑͽ᪝ΑࠐΒĦ  ᨷ਺ᨷᤅϚΦΩϰ͞૿͚ͱΛ
  7. 4USJOHFS΀ᆚď໋ᙚϛϲεΚΜĐ QJMMHPXJUIHPHFOFSBUF -FUTHPHFOFSBUF

  8. HPHFOFSBUFͺᷯΡͭ͸ᑿ͚Νθ⑲ώᓺᕧω⑲ϰ DMJQQFSIPVTFHFO NPOPDISPNFHBOFBSHFO ཋ᪦ମͽ"DUJWF3FDPSEϮΩδͼϦςψώΤᓺᕧ ODXHPUFNQMBUF ᬥᨷͩͱUFNQMBUF 4FU )FBQ ಠᥦᨷᤅ൱ĐͽᷯΡͭ͸θ⑲ώΤᓺᕧ QRVFSOBGGKTPO

    ᴢᓝΚΜᖩ͖.BSTIBM+40/6ONBSTIBM+40/Τᓺᕧ
  9. ͯ΀᳔Κ͔͡Νᑿᠭ᎚ NPDL΀ᓺᕧ WFLUSBNPDLFSZ HPMBOHNPDL +40/ᄑϚΨ⑲ϰώτε΀ᓺᕧ GBWDMJQKXH XJUIHPCJOEBUB

  10. FVSFLB͹΀ሆᠭᆚ ᧸ᘥ΀HPCJOEBUB SPVUJOH΀ᕓᨷϚΦΩϰ͝Λς⑲ξθ⑲ώ΀ᓺᕧ TFSWJDFGBDBEFXPSLFSᄑᥦხᓺᕧͩ͸͖ΝϯϢνύϯΔ ό⑲τมỐᠭ΀ΧϜϯζ⑲μϬϸ ϲνψδĤᤫ΀ᗌ͞ᶶ᠓ͼᐙᐠͲ࣮ͣ૷ͫΝ !.BTBTIJ4BMWBEPS෪ᤫͺͩ͸ YP͹%#͝ΛᬿᨭϧόϰΤᓺᕧ

  11. FVSFLB͹΀ሆᠭᆚ ᧸ᘥ΀HPCJOEBUB SPVUJOH΀ᕓᨷϚΦΩϰ͝Λς⑲ξθ⑲ώ΀ᓺᕧ TFSWJDFGBDBEFXPSLFSᄑᥦხᓺᕧͩ͸͖ΝϯϢνύϯΔ ό⑲τมỐᠭ΀ΧϜϯζ⑲μϬϸ ϲνψδĤᤫ΀ᗌ͞ᶶ᠓ͼᐙᐠͲ࣮ͣ૷ͫΝ !.BTBTIJ4BMWBEPS෪ᤫͺͩ͸ YP͹%#͝ΛᬿᨭϧόϰΤᓺᕧ

  12. ͥͥ͝Λ"45΀ề

  13. HFOFSBUF͹ᑿ͘උ᪽θϣϸώ͵͸ͻ͘ხ͖͸ΝΥͲĦͺ͖͘ᤃዧ ᆚ͚΂+40/΀ϚΨ⑲ϰώτεᓺᕧ --᧣ͼൃᓡ ͹ͺΜ͔͚ͬᩆྥᶡḿ͹៬ᦐΝ ǹ ͶΛ͖ උ᪽θϣϸώ΀ς⑲ξΤಡΒͺ"45Τᑿ͵͸͖ΝΛ͖ͩ "45 ᱢᓯཋየኴ 

    θϸϖΩϮ͞࿖͘ϜϲεϮϥ΀ᬊණᶡḿ  ďͼͻϜϲεϮϥ΀᣾ዳͽؔ๹΀ͼ͖ဒ߸΁ᕭᅊͧΞΝ  ϜϲεϮϥª TDBOOFS ª5PLFO΀ᅾª QBSTFS ª"45  ᶝ᫿ϮΩϛϮϯHPBTU HPQBSTFS HPUPLFO᪰͞᦬ͩ͸͖Ν
  14. HPBTU HPQBSTFS HPUPLFO΀ᑿ͖ፖ ཋየኴ᳼ᓷᠭ΀ؔ਺  *OTQFDU TXJUDIΔͩ͡΁ṞΧκ⑲μϬϸ͹኷᧣΀ϓ⑲ώΤᄌΝ  8BML 

    ຾͵ͱΛ1SJOUຉ΀ؔ਺͹ኴᥦମΤ฼Ν  1SJOU  'QSJOU
  15. ͯ΀᳔BTUΤᑿ͵͸͹͟Νͥͺ  ੩᧣ḑᔡ  ᘊỖᏝࡶႷ΀ຌᒿ IUUQRJJUBDPNLOTIJUFNTGEGCFDDB  FYQPSUͧΞ͸͖Ν͞ዹᑿᠭ΀ม਺΀ݕᬰ  KHBVUIFSPOVTFEFYQPSUT

     Ჩͺͩ͸᪞ΜጿͧΞ͸͖Ν਺ᥙΖየᥙᅾ΀ݕᲇ
  16. ΐͺΓ  HPHFOFSBUF  ཋ᪦ମ΀ቤΓࠐΑΤᑿ͘ͺͥΟͺᫍΑᐠͣͶͶ͘ΐ͡ᑿ͘ͺŸ  ჯͪΚ͘ͼᶡဒ΀෶ᖃ΁UFNQMBUFͽᄢͺͩ͸ᥦხᓺᕧ͹͟ΝͺŸ  WTSFGMFDU 

    ϖϚή⑲ϣϸξďᖩႷĐ᧣ͽዧ᩼͞ပͥΜΖ͖ͫ  ࣮ḝᙉͽQBOJD᧣ͼͥͺͽͼΜΖ͖ͫ  JOUFSGBDF\^Ṟᙼ͖  HPBTU  ᣾៷ͺඦ୯  BOOPUBUJPOΤ᳼ͫϚΨ⑲ϰώτεΤḑᔡͫΝᄑ΁ᷡΜͺၛᲝ͖  ၛᲝ͖͞Θ͚ͽಡΓΝᔉͣΝ  SFBEBCJMJUZJTUIFNPTUJNQPSUBOUGFBUVSFPGQSPHSBNNJOHMBOHVBHF
  17. UIBOLT