> ## Documentation Index
> Fetch the complete documentation index at: https://developers.soax.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Go

> Working Go code for SOAX residential and mobile proxies. Copy-paste examples using net/http.

These examples use Go's standard `net/http` and `net/url` packages. No external dependencies needed. Replace `YOUR_PACKAGE_KEY` with your actual package key from the [dashboard](https://platform.soax.com).

## Residential proxies

### Rotating (new IP every request)

```go theme={null}
package main

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

func main() {
	proxyURL, _ := url.Parse("http://country-us:YOUR_PACKAGE_KEY@proxy.soax.com:1337")
	client := &http.Client{
		Transport: &http.Transport{Proxy: http.ProxyURL(proxyURL)},
	}

	resp, err := client.Get("https://checker.soax.com/api/ipinfo")
	if err != nil {
		fmt.Println("Error:", err)
		return
	}
	defer resp.Body.Close()

	body, _ := io.ReadAll(resp.Body)
	fmt.Println(string(body))
}
```

Each time you run this, you'll get a different IP.

### Session (same IP across requests)

```go theme={null}
package main

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

func main() {
	proxyURL, _ := url.Parse("http://country-us-session-go1:YOUR_PACKAGE_KEY@proxy.soax.com:1337")
	client := &http.Client{
		Transport: &http.Transport{Proxy: http.ProxyURL(proxyURL)},
	}

	for i := 0; i < 3; i++ {
		resp, err := client.Get("https://checker.soax.com/api/ipinfo")
		if err != nil {
			fmt.Println("Error:", err)
			continue
		}
		body, _ := io.ReadAll(resp.Body)
		resp.Body.Close()
		fmt.Printf("Request %d: %s\n", i+1, string(body))
	}
}
```

All three requests will return the same IP.

### Session with timed rotation

Rotate to a new IP every 5 minutes:

```go theme={null}
package main

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

func main() {
	proxyURL, _ := url.Parse("http://country-us-session-job1-rotate-timed_300:YOUR_PACKAGE_KEY@proxy.soax.com:1337")
	client := &http.Client{
		Transport: &http.Transport{Proxy: http.ProxyURL(proxyURL)},
	}

	resp, err := client.Get("https://checker.soax.com/api/ipinfo")
	if err != nil {
		fmt.Println("Error:", err)
		return
	}
	defer resp.Body.Close()

	body, _ := io.ReadAll(resp.Body)
	fmt.Println(string(body))
}
```

### Target a specific city and ISP

```go theme={null}
package main

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

func main() {
	proxyURL, _ := url.Parse("http://country-us-city-los_angeles-isp-comcast:YOUR_PACKAGE_KEY@proxy.soax.com:1337")
	client := &http.Client{
		Transport: &http.Transport{Proxy: http.ProxyURL(proxyURL)},
	}

	resp, err := client.Get("https://checker.soax.com/api/ipinfo")
	if err != nil {
		fmt.Println("Error:", err)
		return
	}
	defer resp.Body.Close()

	body, _ := io.ReadAll(resp.Body)
	fmt.Println(string(body))
}
```

### Session with error retry and lookalike replacement

```go theme={null}
package main

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

func main() {
	proxyURL, _ := url.Parse("http://country-us-session-scrape1-onerror-retry_3-prefer-lookalike:YOUR_PACKAGE_KEY@proxy.soax.com:1337")
	client := &http.Client{
		Transport: &http.Transport{Proxy: http.ProxyURL(proxyURL)},
	}

	resp, err := client.Get("https://checker.soax.com/api/ipinfo")
	if err != nil {
		fmt.Println("Error:", err)
		return
	}
	defer resp.Body.Close()

	body, _ := io.ReadAll(resp.Body)
	fmt.Println(string(body))
}
```

## Mobile proxies

Add `network-mob` to the proxy URL. Everything else works the same way.

### Rotating

```go theme={null}
package main

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

func main() {
	proxyURL, _ := url.Parse("http://network-mob-country-us:YOUR_PACKAGE_KEY@proxy.soax.com:1337")
	client := &http.Client{
		Transport: &http.Transport{Proxy: http.ProxyURL(proxyURL)},
	}

	resp, err := client.Get("https://checker.soax.com/api/ipinfo")
	if err != nil {
		fmt.Println("Error:", err)
		return
	}
	defer resp.Body.Close()

	body, _ := io.ReadAll(resp.Body)
	fmt.Println(string(body))
}
```

### Session

```go theme={null}
package main

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

func main() {
	proxyURL, _ := url.Parse("http://network-mob-country-us-session-mobile1:YOUR_PACKAGE_KEY@proxy.soax.com:1337")
	client := &http.Client{
		Transport: &http.Transport{Proxy: http.ProxyURL(proxyURL)},
	}

	for i := 0; i < 3; i++ {
		resp, err := client.Get("https://checker.soax.com/api/ipinfo")
		if err != nil {
			fmt.Println("Error:", err)
			continue
		}
		body, _ := io.ReadAll(resp.Body)
		resp.Body.Close()
		fmt.Printf("Request %d: %s\n", i+1, string(body))
	}
}
```

### Target a specific carrier

```go theme={null}
package main

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

func main() {
	proxyURL, _ := url.Parse("http://network-mob-country-us-isp-verizon_wireless-session-vz1:YOUR_PACKAGE_KEY@proxy.soax.com:1337")
	client := &http.Client{
		Transport: &http.Transport{Proxy: http.ProxyURL(proxyURL)},
	}

	resp, err := client.Get("https://checker.soax.com/api/ipinfo")
	if err != nil {
		fmt.Println("Error:", err)
		return
	}
	defer resp.Body.Close()

	body, _ := io.ReadAll(resp.Body)
	fmt.Println(string(body))
}
```

## Multiple concurrent sessions

Run several sessions in parallel using goroutines:

```go theme={null}
package main

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

type target struct {
	session string
	country string
}

func main() {
	targets := []target{
		{session: "target_a", country: "us"},
		{session: "target_b", country: "gb"},
		{session: "target_c", country: "de"},
	}

	var wg sync.WaitGroup
	for _, t := range targets {
		wg.Add(1)
		go func(t target) {
			defer wg.Done()
			proxyStr := fmt.Sprintf("http://country-%s-session-%s:YOUR_PACKAGE_KEY@proxy.soax.com:1337", t.country, t.session)
			proxyURL, _ := url.Parse(proxyStr)
			client := &http.Client{
				Transport: &http.Transport{Proxy: http.ProxyURL(proxyURL)},
			}
			resp, err := client.Get("https://checker.soax.com/api/ipinfo")
			if err != nil {
				fmt.Printf("%s: error: %s\n", t.session, err)
				return
			}
			defer resp.Body.Close()
			body, _ := io.ReadAll(resp.Body)
			fmt.Printf("%s: %s\n", t.session, string(body))
		}(t)
	}
	wg.Wait()
}
```

## Expected response

All examples return a JSON response from the SOAX checker:

```json theme={null}
{
  "status": true,
  "data": {
    "ip": "185.123.45.67",
    "country_code": "US",
    "country_name": "United States",
    "region": "California",
    "city": "Los Angeles",
    "isp": "Spectrum",
    "carrier": ""
  }
}
```

## Next steps

<CardGroup cols={2}>
  <Card title="Python examples" icon="code" href="/examples/python">
    Working Python code for SOAX proxies.
  </Card>

  <Card title="Node.js examples" icon="code" href="/examples/nodejs">
    Working Node.js code for SOAX proxies.
  </Card>

  <Card title="Residential proxies" icon="wifi" href="/proxies/residential">
    Full parameter reference.
  </Card>

  <Card title="Error codes" icon="triangle-exclamation" href="/troubleshooting/error-codes">
    What to do when something goes wrong.
  </Card>
</CardGroup>
