博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
来玩下go的http get
阅读量:4140 次
发布时间:2019-05-25

本文共 1256 字,大约阅读时间需要 4 分钟。

       如果写代码的时候, 需要经常去查语法,那说明对语言还不够熟练。来玩下go http get,  主要是练练手:

package mainimport(    "fmt"    "net/http"    "io/ioutil"    "os"    )func main(){    rsp, err := http.Get("http://www.baidu.com")    if err != nil {        fmt.Println("so bad")        os.Exit(1)    }        buf, err := ioutil.ReadAll(rsp.Body)  // byte slice    if err != nil {        fmt.Println("to bad")        os.Exit(2)    }        fmt.Println(string(buf))    }

         结果:

百度一下,你就知道

        不多说。

转载地址:http://zczti.baihongyu.com/

你可能感兴趣的文章
Simple Guide to use the gdb tool in Android environment
查看>>
Netconsole to capture the log
查看>>
Build GingerBread on 32 bit machine.
查看>>
How to make SD Card world wide writable
查看>>
Detecting Memory Leaks in Kernel
查看>>
Linux initial RAM disk (initrd) overview
查看>>
Timestamping Linux kernel printk output in dmesg for fun and profit
查看>>
There's Much More than Intel/AMD Inside
查看>>
apache和tomcat整合
查看>>
java虚拟机错误问题
查看>>
oracle建立表空间
查看>>
oracle分区表的性能提升
查看>>
"Cannot allocate memory" OutofMemory when call Ant to build Polish project in Tomcat
查看>>
dumpcap抓包(python)
查看>>
查看文件是否被其他进程访问
查看>>
字符编码详解
查看>>
python使用dpkt分析wireshak报文(Modbus规约)
查看>>
css中的IFC
查看>>
CentOS 6.5下 mysql用户root登录不了
查看>>
windows + tomcat 部署web服务 http 改为https访问方法
查看>>