IPAddr
byte[4]
IP地址
{127, 2, 0, 1}
String()
127.2.0.1
[127, 2, 0, 1]
package main
import "fmt"
type IPAddr [4]byte
func (p IPAddr) String() string {
return string(p[0]) + "." + string(p[1]) + "." + string(p[2]) + "." + string(p[3]) // this here does not work.
//Even if I simply return p[0] nothing is returned back.
}
func main() {
a := IPAddr{127, 2, 54, 32}
fmt.Println("a:", a)
}