Skip to content

Instantly share code, notes, and snippets.

@josephspurrier
Last active October 3, 2018 15:29
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save josephspurrier/e834f304dc2429962a1782a5963ee505 to your computer and use it in GitHub Desktop.
Save josephspurrier/e834f304dc2429962a1782a5963ee505 to your computer and use it in GitHub Desktop.
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