// 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) != {
fmt.Println("Usage: ./example2 <url>")
os.Exit(-)
}
} // main is the entry point for the application.
func main() {
// Get a response from the web server.
r, err := http.Get(os.Args[])
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

最新文章

  1. 谈谈我的微软特约稿:《SQL Server 2014 新特性:IO资源调控》
  2. 2016总结&amp;2017计划
  3. 第4月第2天 nsinvocation崩溃 mvc videotrack
  4. (Hibernate进阶)Hibernate基本映射(三)
  5. JMir——Java版热血传奇2之资源文件与地图
  6. 【Spring 1】Spring简介
  7. NOI 2014 感想
  8. 激活Navicat?如何注册Navicat?
  9. 【python】使用unix管道pipe处理stdout实时数据
  10. [Postman]拦截器扩展(15)
  11. 网络编程—网络基础概览、socket,TCP/UDP协议
  12. 《Java并发编程的艺术》--Java中的锁
  13. 利用yum搭建lamp环境并进一步创建博客
  14. Vue.js 2.0生命周期
  15. include 模板标签
  16. Notepad++语言格式设置,自定义扩展名关联文件格式
  17. 【three.js练习程序】旋转、缩放场景
  18. java UTC时间和local时间相互转换
  19. [Android&amp;amp;Java]浅谈设计模式-代码篇:观察者模式Observer
  20. Windows上编译LLVM 3.2

热门文章

  1. Different between MB SD Connect Compact 5 and MB SD C4 Star Diagnostic Tool
  2. glog日志库移植Android平台
  3. golang fatal error: all goroutines are asleep - deadlock!
  4. HAProxy实现slave负载均衡[高可用]
  5. 模拟实现ATM+购物商城程序
  6. GDPR
  7. ODAC(V9.5.15) 学习笔记(九)TOraSQLMonitor
  8. Python3 tkinter基础 Canvas coords 移动直线,itemconfig 设置矩形的颜色, delete 删除一条直线
  9. 修改userdata的分区大小【转】
  10. 一些常用的mysql语句实例-以后照写