Budget Proxies logo
GoLang

Send your first GoLang request through a proxy

Go needs no add-ons here. Its net/http Transport, the part that carries each request, is simply pointed at your proxy.

Three steps to see it working

First, buy a plan. Datacenter costs less than the other types, so it suits a first test. Second, copy four details from your dashboard: the host (the proxy server's name or IP address), the port (a number written after the host, with a colon in between), your username and your password. Third, paste them into the sample below. Your login replaces USERNAME and PASSWORD, while gateway.proxy:8080 stands in for your host and port, so swap yours in wherever those appear. Then run it. The sample asks a website which IP address it can see, and if the answer isn't your own IP, the proxy is doing its job. It relies on a library (ready-made code that sends web requests for you); the libraries listed further down need the same details, though each has its own place to put them. Keep in mind that a proxy only changes the address a site sees, so your script must still follow that site's terms and the law where you live.

GoLang
package main

import (
    "fmt"
    "io"
    "net/http"
    "net/url"
)

func main() {
    proxy, _ := url.Parse("http://USERNAME:[email protected]:8080")
    client := &http.Client{Transport: &http.Transport{Proxy: http.ProxyURL(proxy)}}
    resp, _ := client.Get("https://api.ipify.org")
    body, _ := io.ReadAll(resp.Body)
    fmt.Println(string(body)) // the proxy's exit IP
}

These libraries need the same four details

net/http colly chromedp

Writing in a different language?