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

Perl MongerのためのGoの始め方

Perl MongerのためのGoの始め方

Gotanda.pm #8
(2016-03-31 16:30) 37ページがおもいっきり間違っているので修正したものを後ほどUPします

karupanerura

March 30, 2016
Tweet

More Decks by karupanerura

Other Decks in Technology

Transcript

  1. About me • Kenta SATO (id:karupanerura) • Perl/Go/Swift/Kotlin/Java/Crystal/C99/etc.. • Gotanda.pm

    Author • Senior Engineer at Mobile Factory, Inc. • WebApp/iOS/Android/Operation/etc..
  2. Go

  3. GoΛֶͿ • ެࣜͷυΩϡϝϯτ: A Tour of Go • ఆ൪ͷॻ੶: ϓϩάϥϛϯάݴޠGo

    (ະൃച) • WEB+DB PRESS: Vol.82 ͸͡ΊͯͷGo • ษڧձ: (ఆظ։࠵͞Ε͍ͯΔ΋ͷ͸ͳͦ͞͏)
  4. Perl ॲཧܥͷΠϯετʔϧ • anyenv install plenv • plenv install -l

    # όʔδϣϯ֬ೝ • plenv install 5.22.1 • plenv global 5.22.1 • plenv install-cpanm
  5. Perl ϞδϡʔϧͷΠϯετʔϧ • cpanm App::revealup • ςετ͕ϩʔΧϧͰ࣮ߦ͞ΕΔ • cpanm -n

    App::revealup • ςετͳ͠ • cpanm —install-deps . • ΧϨϯτͷґଘϞδϡʔϧΛΠϯετʔϧ
  6. Go ॲཧܥͷΠϯετʔϧ • OS X: brew install go • Debian/Ubuntu:

    apt-get install golang • binary: https://golang.org/dl/ • /usr/bin ͱ͔ʹී௨ʹΠϯετʔϧͰे෼
  7. Go ϞδϡʔϧͷΠϯετʔϧ • go get github.com/karupanerura/gostress • ΠϯετʔϧͷΈ • go

    get -t github.com/karupanerura/gostress • ςετͭͭ͠Πϯετʔϧ • go get -d . • ґଘϞδϡʔϧΛΠϯετʔϧ
  8. PerlͷΤσΟλࣄ৘ • emacs • cperl-mode + flycheck + perl-completion •

    vim • vim-perl + quickrun + perlomni • ͘Θ͘͠ͳ͍
  9. GoͷΤσΟλࣄ৘ • emacs • go-mode + + flycheck + gocode

    • vim • vim-go + vim-godef + gocode • ͘Θ͘͠ͳ͍
  10. Perl ໊લۭؒ • package = ໊લۭؒ = Ϋϥε • private/publicͱ͍͏֓೦͸ແ͍

    • ໊લۭؒͷϨΩγΧϧείʔϓ͸࡞ΕΔ • privateͱͯ͠ѻ͍͍ͨαϒϧʔνϯͷ৔߹͸ ΞϯμʔείΞΛ໊લͷprefixʹ͢Δͷ͕׳श
  11. ܕ

  12. Perl ͷΤϥʔॲཧ • ྫ֎ • eval BLOCK ͷதͰdie͢Δ • $@

    ʹdieʹ౉ͨ͠Scalar஋͕ೖΔ • ී௨
  13. Go ͷΤϥʔॲཧ • ฦΓ஋ͰerrorܕΛฦ͢ͷ͕෩श • result, err := strconv.Atoi(“unko”) •

    if err != nil { … } Ͱશ෦ͳΜͱ͔͢Δ • ෼ذॻ͖๨Εͯ΋ίϯύΠϥ͸ॿ͚ͯ͘ΕΜ