手记

Go 语言 HTTP 客户端(代码高亮测试)

package main

import (
    "fmt"
    "net/http"
    "net/http/httputil"
)

func main() {

    resp, err := http.Get("https://httpbin.org/get")
    if err != nil {
        panic(err)
    }
    defer resp.Body.Close()

    s, err := httputil.DumpResponse(resp, true)
    if err != nil {
        panic(err)
    }
    fmt.Println(string(s))
}
0人推荐
随时随地看视频
慕课网APP