Skip to content

Instantly share code, notes, and snippets.

@josephspurrier
Last active October 3, 2018 15:29
Embed
What would you like to do?
Proxy Testing in Go
package main
import (
"log"
"net/http"
"os"
)
func main() {
os.Setenv("HTTP_PROXY", "127.0.0.1:80")
os.Setenv("HTTPS_PROXY", "127.0.0.1:80")
os.Setenv("NO_PROXY", ".google.com")
_, err := http.Get("http://www.google.com")
if err != nil {
log.Println("Error")
} else {
log.Println("Success")
}
_, err = http.Get("https://www.google.com")
if err != nil {
log.Println("Error")
} else {
log.Println("Success")
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment