package main
import (
// "bufio"
// "io"
"bytes"
"io/ioutil"
"net/http"
)
func main() {
var buf = bytes.NewBufferString("{request: {action: \"GET_COMMON_CATEGORIES\",body:{shopId: \"1000001\",deviceId: \"123455\"}}}")
// buf := bufio.NewReader(s)
resp, err := http.Post("http://www.xxx.net.cn/shop/client", "text/json;charset=UTF-8", buf)
if err != nil {
println(err.Error())
}
// println(resp)
defer resp.Body.Close()
body, err := ioutil.ReadAll(resp.Body)
if err != nil {
println(err.Error())
}
var buf2 = bytes.NewBuffer(body)
println(buf2.String())
//os file bufio-> bytes buffer string
}
有疑问加站长微信联系(非本文作者)