今あらためて読み直したい Go 基礎知識 その2 / golang.tokyo #25

今あらためて読み直したい Go 基礎知識 その2 / golang.tokyo #25

9eed44f137609e6ce3b6f1e14f80b9e1?s=128

Masayuki Izumi

June 18, 2019
Tweet

Transcript

  1. ©2019 Wantedly, Inc. ࠓ͋ΒͨΊͯಡΈ௚͍ͨ͠ Goجૅ৘ใͦͷ golang.tokyo #25 Jun 18, 2019

    - @izumin5210
  2. ©2019 Wantedly, Inc. @izumin5210 Application Engineer, Wantedly People Wantedly, Inc.

    ‣ ͓΋ʹ#BDLFOE&OHJOFFSΛ͍ͯ͠·͢ ‣ (Pͱ3VCZͱɺ·Εʹ8FCϑϩϯτΤϯυ ‣ ࠷ۙͷ͓͖ʹ͍Γ͸HPMBOHPSHYUPPMTHPQBDLBHFTQBDLBHFTUFTU
  3. ©2019 Wantedly, Inc. About "Specification and Internal"

  4. ©2019 Wantedly, Inc. Go Data Structures: Interfaces Go's interfaces—static, checked

    at compile time, dynamic when asked for— are, for me, the most exciting part of Go from a language design point of view. If I could export one feature of Go into other languages, it would be interfaces. Page Title Page Subtitle https://research.swtch.com/interfaces
  5. ©2019 Wantedly, Inc. Go Data Structures: Interfaces https://research.swtch.com/interfaces ‣ 3VTT$PY

    !STD ʹΑΔJOUFSGBDFͷղઆʢʣ  (Pͷൃද͕Β͍͠ ‣ લ൒ͰJOUFSGBDFͷ࢖͍ํͷղઆ  FH  ίϯύΠϧ࣌ܕνΣοΫͭͭ͠%VDL5ZQJOHͰ͖Δʂ  EZOBNJDͰ΋ܕνΣοΫͰ͖Δʂʢ5ZQFTXJUDIFTʣ  ೥લͷهࣄ͚ͩͲࠓݟͯ΋ҧ࿨ײͳ͍ ‣ ޙ൒͸JOUFSGBDFͷσʔλߏ଄΍࣮૷ʹ͍ͭͯ ࢓༷ɾػೳղઆ Go Data Structures: Interfaces
  6. ©2019 Wantedly, Inc. Interfaceͷσʔλߏ଄ ‣ *OUFSGBDF͕ͲͷΑ͏ʹ࣮ͯ͠ݱ͞Ε͍ͯΔ͔  IUUQTHJUIVCDPNHPMBOHHPCMPCHPͱ͔΍Δͱ
 งғؾ͍ۙίʔυ͕ग़ͯ͘Δ ‣

    σʔλߏ଄  ӈਤΈ͍ͨͳ࿩  ͋ΘͤͯಡΈ͍ͨ(P%BUB4USVDUVSFT    ࠓͩͱTSDSVOUJNF\JGBDF SVOUJNF^HP͋ͨΓ ‣ ಺෦࣮૷ʢ௥͍͖Εͣʜʣ ࢓༷ɾػೳղઆ Go Data Structures: Interfaces * https://research.swtch.com/godata
  7. ©2019 Wantedly, Inc. Go Slices: usage and internals https://blog.golang.org/go-slices-usage-and-internals ‣

    "OESFX(FSSBOE BEH ʹΑΔTMJDFͷղઆʢʣ  ͜ͷ࣌఺Ͱ͸·ͩ(P͸ʹͳ͍ͬͯͳ͍ ‣ લ൒Ͱ"SSBZ͓Αͼ4MJDFͷ࢖͍ํͷղઆ  FHॳظԽ NBLF MFO DBQ ΞΫηεͷ࢓ํ   ঺հ͞ΕͯΔίʔυશ෦ࠓͰ΋ಈ͘ ‣ ޙ൒͸TMJDFͷσʔλߏ଄ʹ͍ͭͯ ࢓༷ɾػೳղઆ Go Slices: usage and internals
  8. ©2019 Wantedly, Inc. Sliceͷσʔλߏ଄ɾ࣮૷ ‣ 4MJDFͷσʔλߏ଄ͷ࿩  ಺෦తʹ͸BSSBZ΁ͷQPJOUFS MFO DBQΛ΋͍ͬͯΔ

     ʜΈ͍ͨͳ࿩ ‣ CVJMUJOؔ਺ͷߟ͑ํ  ʮTMJDFͷDBQΛ૿΍͢ʯʹ͸ɺഒͷDBQΛ࣋ͭ
 TMJDFΛ࡞Γ௚ͤ͹͍͍ΑͶDPQZ  ʮTMJDF΁ͷ஋௥Ճʯʹ͸ɺద੾ʹDBQ૿΍ͭͭ͠
 ຤ඌʹDPQZ͢Ε͹͍͍ΑͶBQQFOE ࢓༷ɾػೳղઆ s = s[2:4] s = s[:cap(s)] Go Slices: usage and internals
  9. ©2019 Wantedly, Inc. Arrays, slices (and strings): The mechanics of

    'append' https://blog.golang.org/slices ‣ 3PC1JLFʹΑΔTMJDF·ΘΓͷղઆʢʣ  (PϦϦʔε͔Β೥ޙ͘Β͍ ‣ ʮॳֶऀ͕ʢଞͷݴޠ͔Βͷઌೖ؍Ͱʁʣ4MJDFͭ·͖͕ͣͪʯ
 ͳͷͰɺBQQFOEͷڍಈ͔Βඥղ͍͍ͯ͘ ‣ "SSBZ 4MJDFͷղઆΛͯ͠ɺ4MJDFʹ͍ͭͯ۷ΓԼ͍͛ͯ͘  "TMJDFJTOPUBOBSSBZ"TMJDFEFTDSJCFTBQJFDFPGBOBSSBZ ࢓༷ɾػೳղઆ Arrays, slice (and strings): The mechanics of 'append'
  10. ©2019 Wantedly, Inc. Slice ͷৼΔ෣͍͔ΒڍಈΛཧղ͢Δ ‣ 4MJDFͷ಺෦ߏ଄Λཧղ͢Δ  4MJDFT5IFTMJDFIFBEFS 

    ؔ਺ͷҾ਺΍ϨγʔόʹεϥΠεΛೖΕͯΈͯɺ಺෦ߏ଄ͷཧղͷॿ͚ʹ ‣ (P4MJDFTVTBHFBOEJOUFSOBMTʹ͋ͬͨΑ͏ͳྲྀΕ  4MJDFʹ͸࣮͸DBQ͕͋Δ  େ͖͍4MJDFΛ࡞ΔͨΊʹNBLF͕͋Δ  4MJDFΛFYUFOE͢Δେ͖͍4MJDFʹDPQZ͢Δ  ͜ΕΒΛ૊Έ߹ΘͤͯBQQFOEΛ࣮ݱ͢Δ ‣ ͋ͱ͸OJMTMJDF΍TUSJOHͷ࿩ ࢓༷ɾػೳղઆ Arrays, slice (and strings): The mechanics of 'append' // Append appends the elements to the slice. // Efficient version. func Append(slice []int, elements ...int) []int { n := len(slice) total := len(slice) + len(elements) if total > cap(slice) { // Reallocate. Grow to 1.5 times the new size, newSize := total*3/2 + 1 newSlice := make([]int, total, newSize) copy(newSlice, slice) slice = newSlice } slice = slice[:total] copy(slice[n:], elements) return slice } Snippet from https://blog.golang.org/slices
  11. ©2019 Wantedly, Inc. Constants https://blog.golang.org/constants ‣ 3PC1JLFʹΑΔDPOTUͷղઆʢʣ  (PϦϦʔεͷϲ݄ޙ͘Β͍ ‣

    ม਺ͱ͸ҧ͏ɺzී௨ͷ਺ࣈzͬΆ͘ৼΔ෣͏ఆ਺ʹ͍ͭͯ  qPBU JOU͸μϝɺJOU JOU΋μϝ  Ͱ΋A1e6 * time.SecondA͸ڐ͞ΕΔ ‣ $Ͱ͸͍ΖΜͳʮ਺஋ʯΛࠞͥΒΕΔ͕ɺCVHʹ΋ʜ
 (PͰ͸ېࢭʹ͍ͨ͠ɺ͚ͲAJOU  AΈ͍ͨͳͷ͸ΊΜͲ͍ʜ ࢓༷ɾػೳղઆ Constants
  12. ©2019 Wantedly, Inc. Constants ‣ ADPOTUIFMMP)FMMP ੈքAͷ࣌఺Ͱ͸·ͩTUSJOHͰ͸ͳ͍  6OUZQFETUSJOHDPOTUBOUͰ͋Δ 

    ʢDPOTUBOUUFYUVBMWBMVFͱ΋දݱ͍ͯͨ͠ʣ ‣ ͜ͷ͋ͱ%FGBVMUUZQF͔Βܕͷܾఆͷ࿩ʹҠ͍ͬͯ͘ ‣ ͍࣍ͰTUSJOHҎ֎ͷܕCPPMFBO qPBU ͱଓ͘ ‣ ࠷ޙʹ਺஋ɺ*OUFHFS qPBU DPNQMFYͱ͢΂ͯΛ಺แ͢Δ࿩ ࢓༷ɾػೳղઆ Constants
  13. ©2019 Wantedly, Inc. The Go Memory Model https://golang.org/ref/mem ‣ (PͷϝϞϦϞσϧͷղઆʢʣ

     ͋ΔHPSPVUJOFͰॻ͖ࠐΈ͕͋ͬͨม਺Λ
 ผͷHPSPVUJOFͰಡΈऔΔ͜ͱ͕Ͱ͖Δ͜ͱʹ͍ͭͯ ࢓༷ɾػೳղઆ The Go Memory Model *GZPVNVTUSFBEUIFSFTUPGUIJTEPDVNFOUUPVOEFSTUBOE UIFCFIBWJPSPGZPVSQSPHSBN ZPVBSFCFJOHUPPDMFWFS
 
 %POUCFDMFWFS
  14. ©2019 Wantedly, Inc. Happens before ‣ ·ͣ)BQQFOTCFGPSFͱ͍͏ؔ܎Λఆ͍ٛͯ͠Δ  FHಡΈࠐΈॲཧS͕W΁ͷॻ͖ࠐΈॲཧXΛ؍ଌ͢Δʹ͸
 SEPFTOPUIBQQFOTCFGPSFXͰͳ͍ͱ͍͚ͳ͍

     ԿΛอূ͢Δ͜ͱͰσʔλڞ༗Λ࣮ݱ͍ͯ͠Δ͔Λղઆ͢Δ ‣ ӈͷྫʢDIBOOFMʣͰ͋Ε͹  5IFXSJUFUPBIBQQFOTCFGPSFUIFTFOEPOD  5IFTFOEPODIBQQFOTCFGPSFUIFSFDFJWFPOD  5IFSFDFJWFPODIBQQFOTCFGPSFUIFQSJOU ࢓༷ɾػೳղઆ Go Slices: usage and internals var c = make(chan int, 10) var a string func f() { a = "hello, world" c <- 0 } func main() { go f() <-c print(a) }
  15. ©2019 Wantedly, Inc. Happens before ‣ ·ͣ)BQQFOTCFGPSFͱ͍͏ؔ܎Λఆ͍ٛͯ͠Δ  FHಡΈࠐΈॲཧS͕W΁ͷॻ͖ࠐΈॲཧXΛ؍ଌ͢Δʹ͸
 SEPFTOPUIBQQFOTCFGPSFXͰͳ͍ͱ͍͚ͳ͍

     ԿΛอূ͢Δ͜ͱͰσʔλڞ༗Λ࣮ݱ͍ͯ͠Δ͔Λղઆ͢Δ ‣ ӈͷྫʢDIBOOFMʣͰ͋Ε͹  5IFXSJUFUPBIBQQFOTCFGPSFUIFTFOEPOD  5IFTFOEPODIBQQFOTCFGPSFUIFSFDFJWFPOD  5IFSFDFJWFPODIBQQFOTCFGPSFUIFQSJOU ࢓༷ɾػೳղઆ Go Slices: usage and internals var c = make(chan int, 10) var a string func f() { a = "hello, world" c <- 0 } func main() { go f() <-c print(a) }
  16. ©2019 Wantedly, Inc. Happens before ‣ ·ͣ)BQQFOTCFGPSFͱ͍͏ؔ܎Λఆ͍ٛͯ͠Δ  FHಡΈࠐΈॲཧS͕W΁ͷॻ͖ࠐΈॲཧXΛ؍ଌ͢Δʹ͸
 SEPFTOPUIBQQFOTCFGPSFXͰͳ͍ͱ͍͚ͳ͍

     ԿΛอূ͢Δ͜ͱͰσʔλڞ༗Λ࣮ݱ͍ͯ͠Δ͔Λղઆ͢Δ ‣ ӈͷྫʢDIBOOFMʣͰ͋Ε͹  5IFXSJUFUPBIBQQFOTCFGPSFUIFTFOEPOD  5IFTFOEPODIBQQFOTCFGPSFUIFSFDFJWFPOD  5IFSFDFJWFPODIBQQFOTCFGPSFUIFQSJOU ࢓༷ɾػೳղઆ Go Slices: usage and internals var c = make(chan int, 10) var a string func f() { a = "hello, world" c <- 0 } func main() { go f() <-c print(a) }
  17. ©2019 Wantedly, Inc. Happens before ‣ ·ͣ)BQQFOTCFGPSFͱ͍͏ؔ܎Λఆ͍ٛͯ͠Δ  FHಡΈࠐΈॲཧS͕W΁ͷॻ͖ࠐΈॲཧXΛ؍ଌ͢Δʹ͸
 SEPFTOPUIBQQFOTCFGPSFXͰͳ͍ͱ͍͚ͳ͍

     ԿΛอূ͢Δ͜ͱͰσʔλڞ༗Λ࣮ݱ͍ͯ͠Δ͔Λղઆ͢Δ ‣ ӈͷྫʢDIBOOFMʣͰ͋Ε͹  5IFXSJUFUPBIBQQFOTCFGPSFUIFTFOEPOD  5IFTFOEPODIBQQFOTCFGPSFUIFSFDFJWFPOD  5IFSFDFJWFPODIBQQFOTCFGPSFUIFQSJOU ࢓༷ɾػೳղઆ Go Slices: usage and internals var c = make(chan int, 10) var a string func f() { a = "hello, world" c <- 0 } func main() { go f() <-c print(a) }
  18. ©2019 Wantedly, Inc. Buffered chan, Lock, Once ‣ #V⒎FSSFE$IBOOFMͷৼΔ෣͍΍ͦΕΛԠ༻ͨ͠
 ಉ࣮࣌ߦ਺੍ݶ͖ͭXPSLFS΍ɺ


    -PDL΍0ODF͕ʮͳʹΛอূͯ͘͠ΕΔ͔ʯͷ
 ղઆ͕͋Δ ‣ ϖʔδ಺ΛCFGPSF΍HVBSBOUFFͰHSFQ͢ΔͱಡΈ΍͍͢ ࢓༷ɾػೳղઆ Go Slices: usage and internals var l sync.Mutex var a string func f() { a = "hello, world" l.Unlock() } func main() { l.Lock() go f() l.Lock() print(a) } var a string var once sync.Once func setup() { a = "hello, world" } func doprint() { once.Do(setup) print(a) } func twoprint() { go doprint() go doprint() } Lock Once
  19. ©2019 Wantedly, Inc. Diagnostics https://golang.org/doc/diagnostics.html ‣ (PΤίγεςϜ͕ఏڙ͢Δ
 UPPMTUPEJBHOPTFMPHJDBOEQFSGPSNBODFQSPCMFNT·ͱΊ  ΧςΰϦʹ෼ྨͯ͠ղઆ͢Δ

     1SPpMJOH  5SBDJOH  %FCVHHJOH  3VOUJNFTUBUJTUJDTBOEFWFOUT ࢓༷ɾػೳղઆ Diagnostics
  20. ©2019 Wantedly, Inc. Profiling net/http/pprof & runtime/pprof ‣ ʮॏ͍ͨίʔυʯʮେྔʹݺ͹ΕΔίʔυʯΛ୳͢ॿ͚ʹͳΔ 

    औΕΔσʔλʢGSPNIUUQTHPMBOHPSHQLHSVOUJNFQQSPG1SPpMFʣ - goroutine - stack traces of all current goroutines - heap - a sampling of memory allocations of live objects - allocs - a sampling of all past memory allocations - threadcreate - stack traces that led to the creation of new OS threads - block - stack traces that led to blocking on synchronization primitives - mutex - stack traces of holders of contended mutexes ‣ 1SPEVDUJPOTBGF͚ͩͲɺଟগ͸σάϨ͢ΔΑɻNVMUJSFQMJDBͷ͏ͪͷQSPDFTT͚ͩʹ͠Α͏Ͷɻ  ʜΈ͍ͨͳ࢖͍ํͷίπΈ͍ͨͳͷ΋ॻ͍ͯ͋Δ ࢓༷ɾػೳղઆ Diagnostics
  21. ©2019 Wantedly, Inc. Profiling ࢓༷ɾػೳղઆ Diagnostics Images are from https://golang.org/doc/diagnostics.html#profiling

  22. ©2019 Wantedly, Inc. Profiling ࢓༷ɾػೳղઆ Diagnostics Images are from https://golang.org/doc/diagnostics.html#profiling

  23. ©2019 Wantedly, Inc. Profiling ࢓༷ɾػೳղઆ Diagnostics Images are from https://golang.org/doc/diagnostics.html#profiling

  24. ©2019 Wantedly, Inc. Profiling ࢓༷ɾػೳղઆ Diagnostics Images are from https://golang.org/doc/diagnostics.html#profiling

  25. ©2019 Wantedly, Inc. Tracing golang.org/x/net/trace, net/http/httptrace, ... ‣ ʮ͔͜͜Β͜͜·ͰͰԿNT͔͔ͬͨʯΈ͍ͨͳܭଌ 

    ΞϓϦʹด͡Δ΋ͷ΍ɺෳ਺ΞϓϦʹ·͕ͨΔ΋ͷͳͲʢ෼ࢄτϨʔγϯάʣ  USBDFPCKFDU͸DPOUFYU$POUFYUʹ͍Εͯ఻ൖͤ͞Α͏ʂΈ͍ͨͳϓϥΫςΟε΋ॻ͍ͯ͋Δ ࢓༷ɾػೳղઆ Diagnostics
  26. ©2019 Wantedly, Inc. Debugging Delve, GDB and core dump!! ‣

    ίʔυதʹϒϨʔΫϙΠϯτΛஔ͍ͯɺ
 ͕࣮ͦ͜ߦ͞ΕΔλΠϛϯάͷม਺ΛΈͨΓؔ਺Λεςοϓ࣮ߦͨ͠ΓʜΈ͍ͨͳΞϨ ‣ AHPCVJMEAʹϑϥάΛ଍͢͜ͱͰ࠷దԽΛݮΒ͠ɺσόοά͠΍͘͢Ͱ͖ΔΑΈ͍ͨͳ࿩͕͋Δ ‣ A(053"$&#"$,DSBTIAʹͯ͠ϓϩάϥϜΛ࣮ߦ͠ɺ4*("#35Λ౤͛ΔͱDPSFEVNQు͔ͤΔ͜ͱ΋
 Ͱ͖ΔΒ͍͠ ࢓༷ɾػೳղઆ Diagnostics
  27. ©2019 Wantedly, Inc. Runtime statistics and events runtime, runtime/debug ‣

    SVOUJNFʹऔΕΔॾʑͷ਺ࣈ - runtime.ReadMemStats - debug.ReadGCStats - debug.Stack - debug.WriteHeapDump - runtime.NumGoroutine ‣ SVOUJNFͷΠϕϯτʢTZTDBMM΍($ ͦͷଞ͍Ζ͍ΖʣΛ
 AHPUPPMUSBDFAίϚϯυͰWJTVBMJ[FͰ͖Δ ࢓༷ɾػೳղઆ Diagnostics
  28. ©2019 Wantedly, Inc. About "Concurrency"

  29. ©2019 Wantedly, Inc. Concurrency Page Title Page Subtitle

  30. ©2019 Wantedly, Inc. Concurrency Page Title Page Subtitle

  31. ©2019 Wantedly, Inc. Concurrency is not parallelism https://blog.golang.org/concurrency-is-not-parallelism ‣ 3PC1JLFʹΑΔฒྻͱฒߦͷ࿩ʢʣ

     ͜ͷ࣌఺Ͱ͸·ͩ(P͸ʹͳ͍ͬͯͳ͍ ‣ ͜ͷ࿩ ฒߦॲཧ Concurrency is not parallelism Slide https://talks.golang.org/2012/waza.slide
  32. ©2019 Wantedly, Inc. Concurrency vs. parallelism ฒߦॲཧ Concurrency is not

    parallelism
  33. ©2019 Wantedly, Inc. Concurrency vs. parallelism ‣ $PODVSSFODZ͸ʢݟ͔͚ͤͰ΋͍͍͔Βʣॲཧ͕ಉ࣌ʹߦ͑ΔΑ͏ͳߏ଄  ࣮ࡍʹಉ࣌ʹߦΘΕ͍ͯΔ͔͸ؔ܎ͳ͍

    ‣ 1BSBMMFMJTN͸࣮ࡍʹॲཧ͕ಉ࣌ʹߦ͑Δͱ͍͏͜ͱ ‣ ؔ৺͕ҧ͏ͷͰɺʮ$PODVSSFODZͰ͋Γ1BSBMMFMJTNͰ΋͋Δʯ΋͋Γ͏Δ ※ ॾઆ͋Γ·͢ɻڐͯ͠ɻ ฒߦॲཧ Concurrency is not parallelism
  34. ©2019 Wantedly, Inc. Advanced Go Concurrency Patterns https://blog.golang.org/advanced-go-concurrency-patterns ‣ 4BNFFS"KNBOJ

    4BKNBOJ ʹΑΔฒߦॲཧͷ࣮ફྫͷ঺հʢʣ  HPSPVUJOFDIBOOFMTFMFDUͳͲΛ;ΜͩΜʹ࢖ͬͨྫ ฒߦॲཧ Advanced Go Concurrency Patterns Slide https://talks.golang.org/2013/advconc.slide
  35. ©2019 Wantedly, Inc. ฒߦॲཧ Advanced Go Concurrency Patterns Snippets are

    from https://talks.golang.org/2013/advconc.slide for { if s.closed { close(s.updates) return } items, next, err := s.fetcher.Fetch() if err != nil { s.err = err time.Sleep(10 * time.Second) continue } for _, item := range items { s.updates <- item } if now := time.Now(); next.After(now) { time.Sleep(next.Sub(now)) } } func (s *naiveSub) Close() error { s.closed = true return s.err } ‣ ࠨͷίʔυʹ͸όά͕Օॴ͋Γ·͢ɻͲ͜Ͱ͠ΐ͏ʁ
  36. ©2019 Wantedly, Inc. ฒߦॲཧ Advanced Go Concurrency Patterns Snippets are

    from https://talks.golang.org/2013/advconc.slide for { if s.closed { close(s.updates) return } items, next, err := s.fetcher.Fetch() if err != nil { s.err = err time.Sleep(10 * time.Second) continue } for _, item := range items { s.updates <- item } if now := time.Now(); next.After(now) { time.Sleep(next.Sub(now)) } } func (s *naiveSub) Close() error { s.closed = true return s.err } ‣ ࠨͷίʔυʹ͸όά͕Օॴ͋Γ·͢ɻͲ͜Ͱ͠ΐ͏ʁ ‣ ʜΈ͍ͨͳײ͡Ͱɺ࣮ࡍͷίʔυͷόάΛ௵͍͖ͯ͠ͳ͕Β
 ฒߦॲཧΛ࣮૷͢ΔͨΊͷύλʔϯΛ঺հͯ͘͠ΕΔ

  37. ©2019 Wantedly, Inc. ฒߦॲཧ Advanced Go Concurrency Patterns Snippets are

    from https://talks.golang.org/2013/advconc.slide for { if s.closed { close(s.updates) return } items, next, err := s.fetcher.Fetch() if err != nil { s.err = err time.Sleep(10 * time.Second) continue } for _, item := range items { s.updates <- item } if now := time.Now(); next.After(now) { time.Sleep(next.Sub(now)) } } func (s *naiveSub) Close() error { s.closed = true return s.err } ‣ ࠨͷίʔυʹ͸όά͕Օॴ͋Γ·͢ɻͲ͜Ͱ͠ΐ͏ʁ ‣ ʜΈ͍ͨͳײ͡Ͱɺ࣮ࡍͷίʔυͷόάΛ௵͍͖ͯ͠ͳ͕Β
 ฒߦॲཧΛ࣮૷͢ΔͨΊͷύλʔϯΛ঺հͯ͘͠ΕΔ
 ౴͑͸ࣗ෼Ͱݟ͚ͭͯͶ
  38. ©2019 Wantedly, Inc. Go Concurrency Patterns: Pipelines and cancellation https://blog.golang.org/pipelines

    ‣ 4BNFFS"KNBOJ 4BKNBOJ ʹΑΔύΠϓϥΠϯॲཧͷ࿩ʢʣ ‣ 1JQFMJOFॲཧ͸͍͍ͩͨ͜͏͍͏ͷΛΠϝʔδ͢Δͱྑ͍΍ͭ  ͜Ε΋࣮ࡍͷίʔυΛྫʹͭͭ͠ɺ
 ඞཁͳཁૉΛ࣮͋͛ͯ૷͍ͯ͘͠ ฒߦॲཧ Go Concurrency Patterns: Pipelines and cancellation Image from https://talks.golang.org/2012/waza.slide
  39. ©2019 Wantedly, Inc. PipelineॲཧͰߟྀ͢΂͖͜ͱ ‣ 'BOPVU ‣ 'BOJO ‣ ऴྃॲཧ

    ‣ $BODFMॲཧ ฒߦॲཧ Go Concurrency Patterns: Pipelines and cancellation
  40. ©2019 Wantedly, Inc. PipelineॲཧͰߟྀ͢΂͖͜ͱ ‣ 'BOPVU  ॲཧ͢ΔϫʔΧʔͷ਺Λ૿΍͢ʢDGTDBMFPVUʣ ‣ 'BOJO

     ฒྻʹॲཧͨ݁͠ՌΛগ਺ͷϫʔΧʔʹू໿ͯ͠ॲཧ ‣ ऴྃॲཧ ‣ $BODFMॲཧ ฒߦॲཧ Go Concurrency Patterns: Pipelines and cancellation
  41. ©2019 Wantedly, Inc. PipelineॲཧͰߟྀ͢΂͖͜ͱ ‣ 'BOPVU ‣ 'BOJO ‣ ऴྃॲཧ

     ऴྃ͢Δ·͑ʹɺॲཧதͷϝοηʔδ͸શ෦ऴΘΔ·Ͱ଴ͭʢDGHSBDFGVMTIVUEPXOʣ ‣ $BODFMॲཧ  ֎෦͔ΒͷऴྃγάφϧΛड͚औΕΔΑ͏ʹ͠Α͏ʢFH4*(5&3. λΠϜΞ΢τ DGDPOUFYU$POUFYUʣ ฒߦॲཧ Go Concurrency Patterns: Pipelines and cancellation
  42. ©2019 Wantedly, Inc. About "Naming"

  43. ©2019 Wantedly, Inc. What's in a name? https://talks.golang.org/2014/names.slide ‣ "OESFX(FSSBOE

    BEH ʹΑΔɺ(Pʹ͓͚Δྑ໊͍લ෇͚ʹؔ͢Δ࿩ʢʣ ‣ ʮͲ͏͍͏໊લΛ͚ͭΕ͹Α͍͔ʁʯΛཁૉผʹ঺հ͍ͯ͠Δ  FH  ؔ਺ͷҾ਺໊͸υΩϡϝϯτʹͳΔͷͰɺܕ͚ͩઆ໌Ͱ͖ͳ͍৔߹͸ҙຯͷ͋Δ໊લΛ͚ͭΑ͏  A"GUFS'VOD E%VSBUJPO GGVOD  5JNFSAA6OJY TFD OTFDJOU 5JNFA  ؔ਺ͷϨγʔό໊͸ܕ໊Λ൓өͨ͠ʙจࣈ͘Β͍ʹ͠Α͏ Naming What's in a name? Image from https://talks.golang.org/2012/waza.slide
  44. ©2019 Wantedly, Inc. Naming What's in a name?

  45. ©2019 Wantedly, Inc. Package names https://blog.golang.org/package-names ‣ (Pͷྑ͍ύοέʔδ໊ͷ࿩ʢʣ ‣ ʮྑ͍ύοέʔδ໊ʯʮѱ͍ύοέʔδ໊ʯΛ͍ΖΜͳྫΛڍ͛ͭͭઆ໌͍ͯ͘͠

     FH  ⭕୹ͯ͘Θ͔Γ΍͍͢UJNF MJTU IUUQ  ❌ޠҎ্࢖Θͳ͍DPNQVUF4FSWJDF$MJFOU QSJPSJUZ@RVFVF  ⭕ʢઅ౓͋ΔʣུޠTUSDPOW TZTDBMM GNU Naming What's in a name? Image from https://talks.golang.org/2012/waza.slide
  46. ©2019 Wantedly, Inc. Package names ‣ ίϯςϯπͷ໊લ΍ύοέʔδͷύεͷ໋໊ʹ͍ͭͯ΋ݴٴ͕͋Δ  FH 

    ৑௕ʹ͠ͳ͍❌IUUQ)5514FSWFS ⭕IUUQ4FSWFS  ᐆດ͕͞ͳ͚Ε͹ύοέʔδ໊͸͔Ϳͬͯ΋ྑ͍SVOUJNFQQSPG OFUIUUQQQSPG ‣ ʮ͜Ε͸ྑ͘ͳ໊͍લʂʯνΣοΫϦετ  FH  ҙຯͷͳ໊͍લ͸μϝVUJM DPNNPO  (͢΂ͯͷ"1*Λύοέʔδʹू໿͢Δͷ͸μϝBQJ UZQFT JOUFSGBDFT  ͜͜Ͱ͍͏"1*͸8FC"1*ͷ͜ͱͰ͸ͳ͍
 ʢҙຯ͕޿͍ͷ͸ͦͷͱ͓Γ͕ͩɺίϯςΩετʹΑͬͯ͸ڐ͞ΕΔͷͰ͸ͱݸਓతʹ͸ߟ͍͑ͯΔʣ Naming What's in a name? Image from https://talks.golang.org/2012/waza.slide
  47. ©2019 Wantedly, Inc. References

  48. ©2019 Wantedly, Inc. References Specifications and internal ‣ (P%BUB4USVDUVSFT*OUFSGBDFT 

    IUUQTSFTFBSDITXUDIDPNJOUFSGBDFT  ͋ΘͤͯಡΈ͍ͨ  HPMBOHHPͷTSDSVOUJNFҎԼ  (P%BUB4USVDUVSFTIUUQTSFTFBSDITXUDIDPNHPEBUB ‣ (P4MJDFTVTBHFBOEJOUFSOBMT  IUUQTCMPHHPMBOHPSHHPTMJDFTVTBHFBOEJOUFSOBMT  ͋ΘͤͯಡΈ͍ͨ  'VSUIFS3FBEJOHʹ͕͋ͬͯΔ΍ͭ ‣ "SSBZT TMJDFT BOETUSJOHT 5IFNFDIBOJDTPGBQQFOE  IUUQTCMPHHPMBOHPSHTMJDFT  ͋ΘͤͯಡΈ͍ͨ  4MJDF5SJDLTIUUQTHPMBOHPSHXJLJ4MJDF5SJDLT
  49. ©2019 Wantedly, Inc. References Specifications and internal ‣ $POTUBOUT 

    IUUQTCMPHHPMBOHPSHDPOTUBOUT ‣ 5IF(P.FNPSZ.PEFM  IUUQTHPMBOHPSHSFGNFN  ͋ΘͤͯಡΈ͍ͨ  ʰ(PݴޠʹΑΔฒߦॲཧʱʢΰϧʔνϯΛ౬ਫͷΑ͏ʹ࢖͏ຊʣ ‣ %JBHOPTUJDT  IUUQTHPMBOHPSHEPDEJBHOPTUJDTIUNM  ͋ΘͤͯಡΈ͍ͨ  (PQQSPGϚελʔฤ QQSPGͷ࢓૊Έ ,-BC(BNFT5FDI#MPH
 IUUQLMBCHBNFTUFDICMPHKQLMBCDPNBSDIJWFTQQSPGJOUFSOBMTIUNM  %4"4։ൃऀͷ෦԰QJYJWQSJWBUFJTVDPO߈ུ  
 IUUQETBTCMPHLMBCPSHBSDIJWFTQJYJWJTVDPOIUNM
  50. ©2019 Wantedly, Inc. References Concurrency ‣ $PODVSSFODZJTOPUQBSBMMFMJTN  IUUQTCMPHHPMBOHPSHDPODVSSFODZJTOPUQBSBMMFMJTNIUUQTUBMLTHPMBOHPSHXB[BTMJEF 

    ͋ΘͤͯಡΈ͍ͨ  ʰ(PݴޠʹΑΔฒߦॲཧʱʢΰϧʔνϯΛ౬ਫͷΑ͏ʹ࢖͏ຊʣ ‣ "EWBODFE(P$PODVSSFODZ1BUUFSOT  IUUQTCMPHHPMBOHPSHBEWBODFEHPDPODVSSFODZQBUUFSOTIUUQTUBMLTHPMBOHPSHBEWDPODTMJEF  ͋ΘͤͯಡΈ͍ͨ  ʰ(PݴޠʹΑΔฒߦॲཧʱʢΰϧʔνϯΛ౬ਫͷΑ͏ʹ࢖͏ຊʣ ‣ (P$PODVSSFODZ1BUUFSOT1JQFMJOFTBOEDBODFMMBUJPO  IUUQTCMPHHPMBOHPSHQJQFMJOFT  ͋ΘͤͯಡΈ͍ͨ  ࣮ࡍʹύΠϓϥΠϯॲཧɾฒྻॲཧ΍ͬͯͦ͏ͳίʔυʢFHHPPHMFDMPVEHP AHPNPEUJEZAίϚϯυʣ
  51. ©2019 Wantedly, Inc. References Naming ‣ 8IBUTJOBOBNF   IUUQTUBMLTHPMBOHPSHOBNFTTMJEF

     ͋ΘͤͯಡΈ͍ͨ   ‣ 1BDLBHFOBNFT  IUUQTCMPHHPMBOHPSHQBDLBHFOBNFT  ͋ΘͤͯಡΈ͍ͨ