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

コードで遊ぼう Go #1

YooWaan
October 02, 2015

コードで遊ぼう Go #1

YooWaan

October 02, 2015
Tweet

More Decks by YooWaan

Other Decks in Programming

Transcript

  1. ͍͍ͱ͜Ζ GoogleͰ࡞ͬͯ·͢
 ʢ৴པͰ͖Δ͎ʙʣ ҎԼʹରॲ
 - ιϑτ΢ΣΞ։ൃ଎౓
 - ѻ͍ʹ͍͘λΠϓ
 - Multiple

    core/concurrency ػೳ
 - ੩తϦϯΫωΠςΟϒόΠφϦ
 - GC (ΨϕʔδίϨΫγϣϯ)
 - ڧ͍ܕ෇͚
 - Gorutines / Channels ͱ͔
 - Structs (ߏ଄ମ) / Interface
  2. ։ൃ؀ڥతͳ͜ͱ Go C proj.gyp # gyp ઃఆϑΝΠϧ
 inc/ # ϔομʔϑΝΠϧ


    src/ # ιʔεϑΝΠϧ
 out/Default
 build.ninja # gyp ੜ੒ϑΝΠϧ
 gyp-mac-tool # ಉ͡
 obj/
 <target>.ninja # ϦϯΫΦϓγϣϯͱ͔
 *.o # ΦϒδΣΫτϑΝΠϧ
  3. ίϚϯυϦϑΝϨϯε Go C # ϏϧυσΟΫϨτϦੜ੒
 $ GYP_GENERATORS=ninja gyp proj.gyp 


    --toplevel-dir=. —depth=0 # build
 $ cd out/Default ; ninja # ࣮ߦ
 ./bin/{ exe file } # ࣮ߦίϚϯυදࣔ
 $ ninja -t command # ࡞ۀσΟϨΫτϦͷઃఆ
 $ export GOPATH={path to dir} # build
 $ go install {package name} # ࣮ߦ
 $ ./bin/{ exe file } # ৘ใදࣔ
 $ go env
  4. ࣮ߦ C++(C) Go ՈͷMac mini Ͱ͸ޮՌ͕͋ͬͨ Macbook Pro Ͱ͸ٯʹ஗͍ɾɾɾ thread

    ࢖͏ͱ଎͍Ͷ ฒߦॲཧʹ ͢ΔͱͲͬͪ΋ fib(30)͕ ࠷ॳʹ׬ྃ
  5. ิ଍ C++(C) Go out/Default/obj/run_thread.ninja ʹ flags_cc = -std=c++11 ͕ͳ͍ͱμϝ mainؔ਺ଆͷfor

    ಺ͷ close(ch) , beak ΛίϝϯτΞ΢τ ͢Δͱ deadlock ͯ͠ϓΪϟΕΔΑ (mainؔ਺୭΋௨஌͠ͳ͘ͳͨͷͰ)
  6. ґଘؔ܎ ࣗ෼Ͱղܾ C,C++ͱ͔(άάͬͨΒclibͱ͔ग़͖ͯͨ…) πʔϧͰղܾ java (maven, gradle, sbt) ݴޠσϑΝΫτ؅ཧπʔϧ npm,

    pip, gem, cpan (JS, python, ruby,perl) ͋ΔΑ Go (ศརͱ͸ݴͬͯͳ͍)
 $ go get <package name>
  7. ࢀߟ Go Features and Case Studies
 https://speakerdeck.com/ianlewis/go-features-and-case-studies Google’s Go Language


    http://functionspace.com/topic/2961/Google--039;s-Go-Language Goݴޠ͕μϝͳཧ༝
 http://postd.cc/why-go-is-not-good/ Goίʔυͷॻ͖ํ
 http://golang-jp.org/doc/code.html
  8. ࢀߟ Go Docs
 http://golang-jp.org/doc/ Go FAQ
 https://golang.org/doc/faq Less is exponentially

    more (ωοτͷݪจ)
 http://commandcenter.blogspot.jp/2012/06/less-is-exponentially-more.html Go : ੝Γ্͕Γײ (hype) Λ࣮ྗʹ͢Δ͜ͱ͕ॏཁ ʢҾ༻ݩʣ
 http://wazanova.jp/post/63408341634/go-hype