refactor: 標準ライブラリの uuid パッケージへ移行 - #50
Open
kantacky wants to merge 1 commit into
Open
Conversation
Go 1.27 で標準ライブラリに追加された uuid パッケージ (RFC 9562) を使い、 github.com/google/uuid への直接依存を解消した。 - import を "github.com/google/uuid" から "uuid" へ置き換え - uuid.Nil は標準ライブラリでは関数のため uuid.Nil() へ変更 - 標準ライブラリに名前ベース UUID (version 5) の生成関数がないため、 internal/shared/uuidv5 に RFC 9562 準拠の NewSHA1 を実装した。 移行前と同一の UUID が生成されることを回帰テストで固定している。 Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01DUWzM28D7nBd6uLYz6f6CN
kantacky
requested review from
a team,
Hosoda-abo,
hikaru-0602 and
masaya-osuga
August 20, 2026 23:22
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
変更点
Note
このPRは #49 (Go 1.27 へのアップデート) にスタックしています。base は
claude/go-1-27-upgrade-6geumwです。#49 のマージ後に base がmainに切り替わります。Go 1.27 で標準ライブラリに追加された
uuidパッケージ (RFC 9562) を使うようにし、github.com/google/uuidへの直接依存を解消しました。github.com/google/uuidから標準ライブラリのuuidへ置き換えuuid.Nilは標準ライブラリでは変数ではなく関数のため、uuid.Nil()へ変更(8 箇所)uuid.New()/uuid.Parse()/uuid.UUIDは標準ライブラリでも同じシグネチャのためそのままinternal/shared/uuidv5パッケージを新規追加(下記参照)internal/shared/uuidv5を追加した理由標準ライブラリの
uuidは version 4 / version 7 の生成のみを提供し、名前ベース UUID (version 5, SHA-1) の生成関数を持ちません。deterministicNotificationIDがuuid.NewSHA1(uuid.NameSpaceURL, ...)で通知の冪等キーを生成しており、ここだけ標準ライブラリで置き換えられませんでした。生成される値が変わると既存通知の upsert が重複するため、RFC 9562 §5.5 に沿った実装を
internal/shared/uuidv5に用意し、移行前にgithub.com/google/uuidが生成していた値を期待値としてテストに固定しています。実装は 20 行程度で、namespace と name の SHA-1 に version/variant ビットを立てるだけです。確認したこと
go build ./.../go vet ./.../gofmt -l .(差分なし)/go test ./...すべて成功uuidv5.NewSHA1が移行前のgithub.com/google/uuidと同一の UUID を生成することを 5 ケースで確認(version / variant ビット、決定論性、namespace 定数も検証)uuid.UUIDが pgx v5 のpgtypeで UUID 型としてバイナリ・テキスト両フォーマットで正しくラウンドトリップすることを検証済み([16]byteのためgithub.com/google/uuidと同じ扱いになります)。GORM のモデル定義は変更不要でした補足
github.com/google/uuidはgithub.com/oapi-codegen/runtimeが依存しているため、go.modには indirect 依存として残ります(// indirectへ変化)。生成コードgen/自体は uuid を参照していないため、このリポジトリのコードからの直接参照はゼロになりました。Generated by Claude Code