1、
package main
import (
"fmt"
"net/http"
"net/url"
"strings"
)
func main() {
url := "https://httpbin.org/post"
data := url.Values{}
data.Set("username", "user")
data.Set("password", "pass")
payload := strings.NewReader(data.Encode())
req, err := http.NewRequest("POST", url, payload)
if err != nil {
fmt.Println(err)
return
}
req.Header.Add("Content-Type", "application/x-www-form-urlencoded")
client := &http.Client{}
resp, err := client.Do(req)
if err != nil {
fmt.Println(err)
return
}
defer resp.Body.Close()
fmt.Println("response Status:", resp.Status)
fmt.Println("response Headers:", resp.Header)
body, err := ioutil.ReadAll(resp.Body)
if err != nil {
fmt.Println(err)
return
}
fmt.Println("response Body:", string(body))
}
2、
package main
import (
"bytes"
"fmt"
"io/ioutil"
"net/http"
)
func main() {
url := "http://example.com/path/to/api"
data := []byte("action=wpcom_load_posts&page=2&type=default&exclude=")
req, err := http.NewRequest("POST", url, bytes.NewBuffer(data))
req.Header.Set("Content-Type", "application/x-www-form-urlencoded")
client := &http.Client{}
resp, err := client.Do(req)
if err != nil {
panic(err)
}
defer resp.Body.Close()
body, err := ioutil.ReadAll(resp.Body)
if err != nil {
panic(err)
}
fmt.Println(string(body))
}

![[GO] http请求の模块-微慑信息网-VulSee.com](https://vulsee.com/wp-content/uploads/2024/03/f14df9ce90c84d123ee4b413176ba391.png)

![[GO]如何在Goの环境下添加内核到jupyter notbook-微慑信息网-VulSee.com](https://vulsee.com/wp-content/uploads/2023/05/80404903522f5b93b9ed533154c4b440.png)






![[八卦] 王婷婷—揭秘一个大三女生的性爱录像-微慑信息网-VulSee.com](http://free.86hy.com/crack/pic/1.jpg)
![[随笔]今天国际警察节-微慑信息网-VulSee.com](http://photo.sohu.com/20041017/Img222528326.jpg)

青云网
