Search code examples
gointerfaceuuid

[]uint8 inteface from UUID database data type to STRING or UUID GOLANG


I have problem when return uuid type from database using interface, I geeting back []uint8 not uuid or string,

here []uint8 interface data,

id: [53 102 53 56 99 101 99 98 45 101 48 52 49 45 52 54 52 57 45 98 54 49 55 45 100 53 55 56 102 49 97 50 53 53 51 56]

expected id: 5f58cecb-e041-4649-b617-d578f1a25538

how to convert back []uint8 interface to UUID or string

thanks


Solution

  • If it's just a []uint8 then string(buf) will convert it. You seem to be implying that it's an interface{} though. In that case you would do string(buf.([]uint8)).