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

え、 dep ってもう使わないの!? Go に帰ってきた人のキャッチアップ/What, you...

え、 dep ってもう使わないの!? Go に帰ってきた人のキャッチアップ/What, you don't use dep anymore! Catching up with those returning to the Go language

登壇者名:Masatoshi Tsushima
登壇したイベントタイトル:Go Far. #2 〜ナレッジワーク×メルカリ×newmo×サイバーエージェント×ビットキー〜
登壇したイベントのURL:https://bitkey.connpass.com/event/338871/

More Decks by 株式会社ビットキー / Bitkey Inc.

Other Decks in Technology

Transcript

  1. 2 © Bitkey Inc. Masatoshi Tsushima 津島 雅俊 2004 ソフトウェア開発との出会い

    Webサイトや携帯アプリを作って遊んでいました 2018秋 Bitkeyに参画 当初は主にGoでサーバサイドを開発 2019秋 ファームウェアを開発 デバイスのファームウェアの内製化や新規製品の 開発 2024夏 リプレース案件の立ち上げ 社内の各地に点在する重複機能をGo&Flutterでサ ブシステムに抽出 2022夏 Individual contributor (?) Android/iOS/Flutter、デバイスQA用アプリ、社 内仕様の標準化、Makefile職人、CIおじさん
  2. 5 © Bitkey Inc. Masatoshi Tsushima 津島 雅俊 2004 ソフトウェア開発との出会い

    Webサイトや携帯アプリを作って遊んでいました 2018秋 Bitkeyに参画 当初は主にGoでサーバサイドを開発 2019秋 ファームウェアを開発 デバイスのファームウェアの内製化や新規製品の 開発 2024夏 リプレース案件の立ち上げ 社内の各地に点在する重複機能をGo&Flutterでサ ブシステムに抽出 2022夏 Individual contributor (?) Android/iOS/Flutter、デバイスQA用アプリ、社 内仕様の標準化、Makefile職人、CIおじさん 約5年
  3. 7 7

  4. 8 8

  5. 11 11 © Bitkey Inc. Outline 1. 依存の管理 dep →

    go mod 2. API仕様 go-swagger → ogen 3. データベース gorm→sqlc, pq → pgx 4. ログ logrus/zap/zerolog → slog 5. テスト testing → testify, gomock → uber/gomock 6. エラー errors.Is, errors.As +おまけ
  6. 13 13 © Bitkey Inc. 感想: もうgoだけで良いんですね! dep → go

    mod • よかった!ありがとう! • go mod init example.com/hello で初期化 • go get github.com/org/repo で追加 • go mod tidy で整理 昔はgodep, glide, depってのがあってな…
  7. 15 15 © Bitkey Inc. 感想: 新しいOpenAPIが使える go-swagger → ogen

    • v3 のツールが揃ってる • Redocly CLIが便利 ◦ preview/lint/split GraphQL, gRPCもチラ見はした
  8. 17 17 © Bitkey Inc. 感想: そんなに大きくは変わってないかな gorm → sqlc

    • gorm v2もあるけどSQL中心の方が好み pq → pgx/stdlib • 新しく始めるならpgxかな • とはいえ他と組み合わせるならstdlibが楽 ◦ AlloyDB, Cloud SQL, OpenTelemetry go-migrateは健在っすね
  9. 19 19 © Bitkey Inc. 感想: 速さ競ってた気がするけどもうええでしょう logrus/zap/zerolog → slog

    • 標準ライブラリにいる! • zap/zerologは相変わらず速そうだけど Cloud Loggingとの統合に集中します
  10. 21 21 © Bitkey Inc. 感想: Copilot便利ですね testing → testify

    • 男は黙ってtesting…じゃなくてもええか gomock → uber/gomock • golangでメンテしなくなったのか でもCopilotには言わないと生成済みmock使ってくれない
  11. 23 23 © Bitkey Inc. 感想: wrapね… errors.Is • なるほど

    errors.As • まだちょっと使いこなす自信無いかも • switch err.(type)できないのちょっと不満
  12. 25 25 © Bitkey Inc. 昔ほどハッスルしてない…! • 標準に落ち着いた ◦ 依存の管理は

    go mod ◦ ログは slog • 他も身構えるほど変わってない • 言語の新機能 ◦ ジェネリクスが欲しい場面にまだ出会ってない ◦ イテレータはちょっとあるかも Goよりドメインそのものとかクラウドの使い方に時間使えてる気がする
  13. 27 27 © Bitkey Inc. go generate → Makefile 参考:

    Makefileで必要なファイルだけgo generateするレシピ 必要な再生成だけ行いたい OGEN := go run github.com/ogen-go/ogen/cmd/ogen OGEN_COMPONENTS := $(wildcard openapi/components/*/*.yaml) OGEN_TARGET := internal/api/ogen/oas_server_gen.go ogen: $(OGEN_TARGET) clean-ogen: rm -rf $(dir $(OGEN_TARGET))* internal/api/ogen/oas_server_gen.go: spec/config.yaml spec/api.yaml $(OGEN_COMPONENTS) $(OGEN) -package ogen -target internal/api -config spec/config.yaml -clean spec/api.yaml
  14. 28 28 © Bitkey Inc. go generate → Makefile 参考:

    Is there a smarter alternative to "watch make"? Watch したい watch: while true; do $(MAKE) -j4 -q || $(MAKE) -j4; sleep 1; done