diff --git a/internal/lidarrrequests/reconciler.go b/internal/lidarrrequests/reconciler.go index 62ad1d75..3546dc1b 100644 --- a/internal/lidarrrequests/reconciler.go +++ b/internal/lidarrrequests/reconciler.go @@ -66,35 +66,19 @@ func formatUUIDForBus(u pgtype.UUID) string { if !u.Valid { return "" } - return string([]byte{ - hex(u.Bytes[0]>>4), hex(u.Bytes[0]&0xf), - hex(u.Bytes[1]>>4), hex(u.Bytes[1]&0xf), - hex(u.Bytes[2]>>4), hex(u.Bytes[2]&0xf), - hex(u.Bytes[3]>>4), hex(u.Bytes[3]&0xf), - '-', - hex(u.Bytes[4]>>4), hex(u.Bytes[4]&0xf), - hex(u.Bytes[5]>>4), hex(u.Bytes[5]&0xf), - '-', - hex(u.Bytes[6]>>4), hex(u.Bytes[6]&0xf), - hex(u.Bytes[7]>>4), hex(u.Bytes[7]&0xf), - '-', - 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 + const hex = "0123456789abcdef" + out := make([]byte, 36) + pos := 0 + for i, b := range u.Bytes { + if i == 4 || i == 6 || i == 8 || i == 10 { + out[pos] = '-' + pos++ + } + out[pos] = hex[b>>4] + out[pos+1] = hex[b&0xf] + pos += 2 } - return 'a' + (b - 10) + return string(out) } // Run blocks until ctx is cancelled, ticking every r.tick. Errors from