Why can not 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) The error: cannot convert b (type [16]byte) to type string I find the solution at this problem Change to: pass = string(b[:]) But why can not use it like this? pass = string(b) 回答1: Short answer is because the Go Language Specification does not permit it. Quoting from the Go Language Specification: Conversions: A non-constant value x can be