go语言网络编程

 1 package main
 2 
 3 import (
 4     "fmt"
 5     "net"
 6     "os"
 7 )
 8 
 9 func main() {
10     if len(os.Args) != 2 {
11         fmt.Fprintf(os.Stderr, "Usage: %s ip-addr\n", os.Args[0])
12         os.Exit(1)
13     }
14     name := os.Args[1]
15     addr := net.ParseIP(name)
16     if addr == nil {
17         fmt.Println("Invalid address")
18     } else {
19         fmt.Println("The address is ", addr.String())
20     }
21     os.Exit(0)
22 }

 

posted @ 2019-10-27 22:29  尘归风  阅读(121)  评论(0编辑  收藏  举报