diff --git a/fieldapi.go b/fieldapi.go index 25a6615..351e78d 100644 --- a/fieldapi.go +++ b/fieldapi.go @@ -71,7 +71,7 @@ func Float[T ~float32 | ~float64](key string, val T) Field { } // String constructs a field containing a key and String value. -func String[T ~string](key string, val T) Field { +func String[T ~string | ~[]byte](key string, val T) Field { return Field{Key: key, Type: StringType, String: string(val)} } diff --git a/fieldapi_test.go b/fieldapi_test.go index 465ba5d..0cbfdb3 100644 --- a/fieldapi_test.go +++ b/fieldapi_test.go @@ -68,6 +68,10 @@ func TestFieldString(t *testing.T) { _ = String("string", "foo") type myString string _ = String("string", myString("foo")) + + type myByteSlice string + _ = String("string", []byte{}) + _ = String("string", myByteSlice([]byte{})) } func TestFieldStringer(t *testing.T) {