Convert a byte array to a string array [duplicate]
问题 This question already has answers here : Convert a byte to a string in Go (5 answers) Closed 2 years ago . In the following method, I attempted to redefine the string method on the IPAddr type by appending bytes to an array of string type IPAddr [4]byte func (ip IPAddr) String() string { var s []string for _, i := range ip { s = append(s, i) } return fmt.Sprintf(strings.Join(s, ".")) } cannot use i (type byte) as type string in append playground 回答1: Since your type is an array with a small