Skip to content

refactor: use Go 1.27 standard library uuid instead of satori/go.uuid - #276

Merged
whywaita merged 5 commits into
masterfrom
refactor/use-std-uuid
Aug 20, 2026
Merged

whywaita merged 5 commits into
masterfrom
refactor/use-std-uuid

Conversation

@whywaita

@whywaita whywaita commented Aug 20, 2026

Copy link
Copy Markdown
Owner

Summary

内部的に使っているUUID実装を、サードパーティの github.com/satori/go.uuid から Go 1.27 で標準ライブラリに追加された uuid パッケージに移行します。

Changes

UUID 移行(API 対応表)

  • uuid.FromString(...)uuid.Parse(...)
  • uuid.FromStringOrNil(...)uuid.MustParse(...)(テストの固定 UUID 文字列のみ)
  • uuid.Equal(a, b)a == b(std uuid.UUID は比較可能な [16]byte
  • uuid.NewV4() / uuid.UUID / uuid.UUID{} / .String() は API 互換
  • go.modgo ディレクティブを 1.251.27 に引き上げ、satori/go.uuid 依存を削除

DB 層(mysql)
std uuid.UUID は satori と違い driver.Valuer / sql.Scanner を持たないため、UUID 列(VARCHAR(36))との入出力を文字列で処理:

  • INSERT/WHERE: uuid.UUID.String() をバインド(CreateTarget, EnqueueJob
  • SELECT: UUID 列を string に持つ shadow 構造体にスキャン → uuid.Parse で標準型に復元
  • ドメイン型は std uuid.UUID のまま(memory/web/runner/starter への波及なし)

CI

  • staticcheck@latest(v0.7.0)は Go 1.27 の export data(version 4)を解析できず内部エラーになるため、v0.8.0-rc.1 に固定(Go 1.27 対応)
  • Dockerfile の builder イメージを golang:1.25golang:1.27 に更新

Verification

  • go build ./... / go vet ./... OK
  • テスト(mysql/web 含む)CI で全パス
  • docker-build-test / docker-build-sha パス
  • staticcheck / lint パス
  • PR mergeable 確認済み

Replace github.com/satori/go.uuid with the standard library uuid package
added in Go 1.27.

- uuid.FromString -> uuid.Parse
- uuid.FromStringOrNil -> uuid.MustParse
- uuid.Equal(a, b) -> a == b (UUID is a comparable [16]byte)
- uuid.NewV4 / uuid.UUID / uuid.UUID{} map 1:1

Bump go directive 1.25 -> 1.27 and drop the satori/go.uuid module.
go.mod now requires Go >= 1.27 (standard library uuid), and the
Dockerfile uses GOTOOLCHAIN=local, so the builder image must be 1.27.
staticcheck@latest resolves to v0.7.0 (2026.1), whose bundled x/tools
cannot decode Go 1.27's export data (version 4) and fails with an internal
error. v0.8.0-rc.1 (2026.2rc1) supports Go 1.27 and passes cleanly on the
module.
The standard library uuid.UUID is a [16]byte with no driver.Valuer or
sql.Scanner, unlike satori/go.uuid. UUID columns are VARCHAR(36), so:

- Writes: pass uuid.UUID.String() when binding (CreateTarget, EnqueueJob).
- Reads: scan rows into shadow structs whose UUID columns are strings, then
  parse back into datastore entities with uuid.Parse.

Keeps the domain type as std uuid.UUID (no ripple into memory/web/runner/
starter) and confines DB conversion to the mysql package.
The sql.*FromSQL test helpers bound uuid.UUID directly to prepared
statements, which fails with std uuid (no driver.Valuer/Scanner). Bind
uuid.String() and scan into local shadow rows (UUID columns as strings)
then parse back into datastore entities.
@whywaita
whywaita merged commit 4fc84c7 into master Aug 20, 2026
5 checks passed
@whywaita
whywaita deleted the refactor/use-std-uuid branch August 20, 2026 06:21
whywaita added a commit that referenced this pull request Aug 20, 2026
@whywaita
whywaita restored the refactor/use-std-uuid branch August 20, 2026 06:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant