1. package main
    2. import (
    3. "fmt"
    4. "net/http"
    5. "net/url"
    6. )
    7. func main() {
    8. proxy := func(_ *http.Request) (*url.URL, error) {
    9. return url.Parse("http://127.0.0.1:8087")
    10. }
    11. transport := &http.Transport{Proxy: proxy}
    12. client := &http.Client{Transport: transport}
    13. resp, err := client.Get("http://www.google.com")
    14. ...
    15. }