fix(#392): simplify uuid formatter — gofmt-clean loop

The hand-unrolled byte-pair version in reconciler.go tripped gofmt -s
and goimports. Replaced with the same loop-based formatter that
internal/library/eventbus.go uses — same behaviour, fewer lines, lint
clean. Two copies of the helper still exist (one per package) to keep
the no-back-edge property for both internal/library and
internal/lidarrrequests, but they're now identical and the duplication
is tiny.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-05-12 22:21:38 -04:00
parent f7dfeff256
commit 15063ca0b4
+12 -28
View File
@@ -66,35 +66,19 @@ func formatUUIDForBus(u pgtype.UUID) string {
if !u.Valid { if !u.Valid {
return "" return ""
} }
return string([]byte{ const hex = "0123456789abcdef"
hex(u.Bytes[0]>>4), hex(u.Bytes[0]&0xf), out := make([]byte, 36)
hex(u.Bytes[1]>>4), hex(u.Bytes[1]&0xf), pos := 0
hex(u.Bytes[2]>>4), hex(u.Bytes[2]&0xf), for i, b := range u.Bytes {
hex(u.Bytes[3]>>4), hex(u.Bytes[3]&0xf), if i == 4 || i == 6 || i == 8 || i == 10 {
'-', out[pos] = '-'
hex(u.Bytes[4]>>4), hex(u.Bytes[4]&0xf), pos++
hex(u.Bytes[5]>>4), hex(u.Bytes[5]&0xf), }
'-', out[pos] = hex[b>>4]
hex(u.Bytes[6]>>4), hex(u.Bytes[6]&0xf), out[pos+1] = hex[b&0xf]
hex(u.Bytes[7]>>4), hex(u.Bytes[7]&0xf), pos += 2
'-',
hex(u.Bytes[8]>>4), hex(u.Bytes[8]&0xf),
hex(u.Bytes[9]>>4), hex(u.Bytes[9]&0xf),
'-',
hex(u.Bytes[10]>>4), hex(u.Bytes[10]&0xf),
hex(u.Bytes[11]>>4), hex(u.Bytes[11]&0xf),
hex(u.Bytes[12]>>4), hex(u.Bytes[12]&0xf),
hex(u.Bytes[13]>>4), hex(u.Bytes[13]&0xf),
hex(u.Bytes[14]>>4), hex(u.Bytes[14]&0xf),
hex(u.Bytes[15]>>4), hex(u.Bytes[15]&0xf),
})
}
func hex(b byte) byte {
if b < 10 {
return '0' + b
} }
return 'a' + (b - 10) return string(out)
} }
// Run blocks until ctx is cancelled, ticking every r.tick. Errors from // Run blocks until ctx is cancelled, ticking every r.tick. Errors from