Last active
October 3, 2018 15:29
-
-
Save josephspurrier/e834f304dc2429962a1782a5963ee505 to your computer and use it in GitHub Desktop.
Proxy Testing in Go
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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