util/rands: add package with HexString func

We use it a number of places in different repos. Might as well make
one. Another use is coming.

Updates #cleanup

Change-Id: Ib7ce38de0db35af998171edee81ca875102349a4
Signed-off-by: Brad Fitzpatrick <bradfitz@tailscale.com>
This commit is contained in:
Brad Fitzpatrick
2023-09-05 09:02:40 -07:00
committed by Brad Fitzpatrick
parent f824274093
commit 7175f06e62
5 changed files with 45 additions and 13 deletions

15
util/rands/rands_test.go Normal file
View File

@@ -0,0 +1,15 @@
// Copyright (c) Tailscale Inc & AUTHORS
// SPDX-License-Identifier: BSD-3-Clause
package rands
import "testing"
func TestHexString(t *testing.T) {
for i := 0; i <= 8; i++ {
s := HexString(i)
if len(s) != i {
t.Errorf("HexString(%v) = %q; want len %v, not %v", i, s, i, len(s))
}
}
}