mholt/curl-to-go

curl --socks5 127.0.0.1:1080 url

kzhui125 opened this issue · 0 comments

curl --socks5 127.0.0.1:1080 http://xyz.com
	proxyUrl, err := url.Parse("socks5://127.0.0.1:1080")
	httpClient := &http.Client{Transport: &http.Transport{Proxy: http.ProxyURL(proxyUrl)}}
	u := "http://xyz.com"
	req, err := http.NewRequest("GET", u, nil)
	if err != nil {
		panic(err)
	}
	resp, err := httpClient.Do(req)
	if err != nil {
		panic(err)
	}
	defer resp.Body.Close()
	body, err := ioutil.ReadAll(resp.Body)
	if err != nil {
		panic(err)
	}
	log.Println(string(body))