title: Golang TLS socket ignores HTTP_PROXY environment variable
body: <p>I'm making a HTTP request using socket in Golang. I need the request to be made via proxy server to hide my ip. I set the proxy using <code>os.Setenv(&quot;HTTP_PROXY&quot;, &quot;http://ip:port&quot;)</code> however the socket ignores this variable and makes the request without the proxy. Here's my code:</p>
  <pre class="lang-golang prettyprint-override"><code>package main
  
  import (
      &quot;crypto/tls&quot;
      &quot;fmt&quot;
      &quot;os&quot;
  )
  
  func sendSocketRequest() {
      recv := make([]byte, 4096)
      conn, _ := tls.Dial(&quot;tcp&quot;, &quot;api.ipify.org&quot;+&quot;:443&quot;, nil)
      conn.Write([]byte(&quot;GET / HTTP/1.1\r\nHost: api.ipify.org\r\n\r\n&quot;))
      conn.Read(recv)
      fmt.Println(string(recv))
      conn.Close()
  }
  
  func main() {
      os.Setenv(&quot;HTTP_PROXY&quot;, &quot;http://193.27.23.62:9150&quot;)
      os.Setenv(&quot;HTTPS_PROXY&quot;, &quot;http://193.27.23.62:9150&quot;)
  
      sendSocketRequest()
  }
  </code></pre>
  <p>In addition, I tried that with normal HTTP client <code>net/http</code> and it worked just fine. The request was made via proxy.</p>
  <p>Thank you for your help.</p>