#Go

35 件の記事

Go実践 #1 はじめてのHTTPサーバー
読了 5分

Go実践 #1 はじめてのHTTPサーバー

net/httpパッケージひとつで始める最小のサーバー。ListenAndServe、HandleFunc、ResponseWriter、そしてgraceful shutdown。

Go上級 #7 コード生成 — go generate と stringer
読了 6分

Go上級 #7 コード生成 — go generate と stringer

reflect のランタイムコストを避ける道 — コンパイル時コード生成。go generate ワークフロー、stringer、mockgen のようなツール。

Go上級 #6 プロファイリング — pprof と benchmark
読了 5分

Go上級 #6 プロファイリング — pprof と benchmark

go test -bench、pprof で CPU・メモリ・ゴルーチンプロファイルを取る。性能を推測ではなく計測で扱う方法。

Go上級 #5 unsafe と cgo — 安全領域の外へ
読了 6分

Go上級 #5 unsafe と cgo — 安全領域の外へ

unsafe.Pointer の 4 つのルール、cgo のトレードオフ、そしてどちらもほぼ使ってはいけない理由。

Go上級 #4 reflect パッケージ — ランタイムに型を扱う
読了 6分

Go上級 #4 reflect パッケージ — ランタイムに型を扱う

reflect.Type と reflect.Value、struct タグの読み取り、動的呼び出し。シリアライゼーションライブラリの内側で見かけるツール。

Go上級 #3 ジェネリクス — type parameter と constraint
読了 6分

Go上級 #3 ジェネリクス — type parameter と constraint

Go 1.18 に入ったジェネリクス。type parameter 文法、constraint、comparable と ~ トークン、そしていつ使わないほうが良いか。

Go上級 #2 メモリモデルと sync パッケージ
読了 6分

Go上級 #2 メモリモデルと sync パッケージ

Mutex、RWMutex、WaitGroup、Once、atomic — チャネルではない共有メモリ同期ツール。いつ何を使うか。

Go上級 #1 並行性パターン — fan-out・fan-in・pipeline
読了 6分

Go上級 #1 並行性パターン — fan-out・fan-in・pipeline

ゴルーチンとチャネルを組み立てて作る標準的な並行性パターン — pipeline、fan-out/fan-in、semaphore まで。

Go中級 #7 標準ライブラリツアー
読了 6分

Go中級 #7 標準ライブラリツアー

Go 標準ライブラリでよく使うもの — io、fmt、strings、time、sort、encoding/json までを一気に見渡します。

Go中級 #6 テスティング — testing パッケージと table-driven
読了 6分

Go中級 #6 テスティング — testing パッケージと table-driven

Go 標準 testing パッケージでユニットテストとベンチマークを書く方法、そして Go コードの標準パターンである table-driven テスト。

Go中級 #5 context.Context 深掘り
読了 6分

Go中級 #5 context.Context 深掘り

Goの標準キャンセル・タイムアウト・リクエストデータ伝達ツール。context が並行コードの骨格になる理由。

Go中級 #4 selectとタイムアウト
読了 5分

Go中級 #4 selectとタイムアウト

複数のチャネルを同時に扱うselect文、そしてタイムアウト・キャンセル・ノンブロック通信のような実践パターン。