LoginSignup
4
4

More than 5 years have passed since last update.

ヒカルのGO! hikarie.go #2

Posted at

Official

ハンズオン

001_net_http

  • http.ListenAndServe(":4000", nil)の":4000"はコロンを入れて文字列にするには理由がある。(理由を聞き逃した・・・)
  • Revelの(revel run)だと変更検知して再起動してくれる。watcherでも管理出来る

002_net_http_inside

  • HundlerFuncの話
    • Golangは複数のやり方があるので、自分で気持ちが良い方法を選ぶのが吉
  • fmt.Fprintの話
  • 2つともシンタックスシュガー
  • ListenAndServeの話
    • httpリクエストは必ずgoroutineが上がるようになっている。

003_encoding_json

  • MarshalとUnmarshalこの2つの関数さえ覚えておけば使える
  • バッククォート(`)はダブルクオート(")とかエスケープ不要で書ける
  • アノテーション便利
  • JavaでいうtoStringのようにgolangにもString関数を実装させると吉
  • jsonで型作ろうとするけど、フレキシブルでスキーマがよく分からない時はinterface{}を使います。(何でもいい型)

004_file

  • io/ioutilが一番簡単なファイル操作モジュール
  • デカいFileはバッファリング

005_json_api

  • 総仕上げ。
4
4
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
4
4