在线时间:8:00-16:00
迪恩网络APP
随时随地掌握行业动态
扫描二维码
关注迪恩网络微信公众号
// Sample program to show how to write a simple version of curl using // the io.Reader and io.Writer interface support. package main import ( "fmt" "io" "net/http" "os" ) // init is called before main. func init() { if len(os.Args) != 2 { fmt.Println("Usage: ./example2 <url>") os.Exit(-1) } } // main is the entry point for the application. func main() { // Get a response from the web server. r, err := http.Get(os.Args[1]) if err != nil { fmt.Println(err) return } // Copies from the Body to Stdout. io.Copy(os.Stdout, r.Body) if err := r.Body.Close(); err != nil { fmt.Println(err) } } 执行 go run test.go http://www.baidu.com
|
请发表评论