golang []byte和string的高性能转换 在fasthttp的最佳实践中有这么一句话: Avoid conversion between []byte and string, since this may result in memory allocation+copy. Fasthttp API provides functions for both []byte and string - use these functions instead of converting manu…
string 不能直接和byte数组转换 string可以和byte的切片转换 1,string 转为[]byte var str string = "test" var data []byte = []byte(str) 2,byte转为string var data [10]byte byte[0] = 'T' byte[1] = 'E' var str string = string(data[:])…