Go 如何将uint8数组转换为字符串
将[]uint8转换为字符串的最佳方式是什么 我正在使用 阅读卡夫卡的事件。但它不会返回纯字符串事件。 它返回类型为[]uint8的事件 如何将此事件从[]uint8转换为字符串?,这意味着uint8的片段aka[]uint8也是byte aka[]byte的片段 字节片和字符串可以直接转换,因为字符串由字节片支持:Go 如何将uint8数组转换为字符串,go,type-conversion,Go,Type Conversion,将[]uint8转换为字符串的最佳方式是什么 我正在使用 阅读卡夫卡的事件。但它不会返回纯字符串事件。 它返回类型为[]uint8的事件 如何将此事件从[]uint8转换为字符串?,这意味着uint8的片段aka[]uint8也是byte aka[]byte的片段 字节片和字符串可以直接转换,因为字符串由字节片支持: myByteSlice := []byte{ ... } // same as myByteSlice := []uint8{ ... } myString := stri
myByteSlice := []byte{ ... } // same as myByteSlice := []uint8{ ... }
myString := string(myByteSlice) // myString is a string representation of the byte slice
myOtherSlice := []byte(myString) // Converted back to byte slice
看这里:只需Stringuint8切片。请注意,这是一个切片,而不是数组。