reflect: add (u)int -> string conversions

This commit is contained in:
Damian Gryski
2026-05-26 13:45:18 -07:00
committed by Damian Gryski
parent f31b39775f
commit e111b489ec
+17 -4
View File
@@ -1686,12 +1686,25 @@ func makeComplex(flags valueFlags, f complex128, t *RawType) Value {
return v
}
func cvtIntString(src Value, t *RawType) Value {
panic("cvtUintString: unimplemented")
//go:linkname stringFromUnicode runtime.stringFromUnicode
func stringFromUnicode(x rune) string
func cvtIntString(v Value, t *RawType) Value {
b := stringFromUnicode(rune(v.Int()))
return Value{
typecode: t,
value: unsafe.Pointer(&b),
flags: v.flags,
}
}
func cvtUintString(src Value, t *RawType) Value {
panic("cvtUintString: unimplemented")
func cvtUintString(v Value, t *RawType) Value {
b := stringFromUnicode(rune(v.Uint()))
return Value{
typecode: t,
value: unsafe.Pointer(&b),
flags: v.flags,
}
}
//go:linkname stringToRunes runtime.stringToRunes