Skip to content

Commit

Permalink
Update ParseIP
Browse files Browse the repository at this point in the history
修正函数输出错误;
补充输入参数说明
  • Loading branch information
lomoalbert committed Jul 19, 2014
1 parent 9cb3856 commit 05268d6
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 4 deletions.
2 changes: 1 addition & 1 deletion net/IPv4Mask.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@

函数功能

- 生成IP掩码的字节列表
- 生成IP掩码

代码实例:

Expand Down
13 changes: 10 additions & 3 deletions net/ParseIP.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

参数列表:

- s ip地址字符串
- s ip地址字符串,可以是IPv4或IPv6格式( ("74.125.19.99") or ("2001:4860:0:2001::68") )

返回列表:

Expand All @@ -19,5 +19,12 @@

func main() {
ip := net.ParseIP("74.125.19.99")
fmt.Printf("IP:%#v",ip) //返回 IP:[]byte{0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0xff, 0xff, 0x4a, 0x7d, 0x13, 0x63}
}
fmt.Printf("%#v",ip)
ip = net.ParseIP("2001:4860:0:2001::68")
fmt.Printf("%#v",ip)
}

函数输出:

net.IP{0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0xff, 0xff, 0x4a, 0x7d, 0x13, 0x63}
net.IP{0x20, 0x1, 0x48, 0x60, 0x0, 0x0, 0x20, 0x1, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x68}

0 comments on commit 05268d6

Please sign in to comment.