How do I convert [Size]byte to string in Go?
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I have a sized byte array that I got after doing md5.Sum() . data := []byte("testing") var pass string var b [16]byte b = md5.Sum(data) pass = string(b) I get the error: cannot convert b (type [16]byte) to type string 回答1: You can refer to it as a slice: pass = string(b[:]) 回答2: A little late but keep in mind that using string(b[:]) will print mostly invalid characters. If you're trying to get a hex representation of it like php you can use something like: data := []byte("testing") b := md5.Sum(data) //this is mostly invalid characters fmt