title: Redefine const in golang for test
body: <p>I'm writing an http client for a service and for testing I want to use a <code>net/http/httptest</code> server instead of calling out to the remote API.  I can easily do this if I make the <code>baseUrl</code> a global variable which gets set to the url of my test server. However, this makes the production code more fragile because <code>baseUrl</code> can also be changed during runtime.  My preference would be to make <code>baseUrl</code> a <code>const</code> for production code but still be able to change.</p>
  
  <pre><code>package main
  const baseUrl = "http://google.com"
  
  // in main_test.go
  ts := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
    ...
   }
  const baseUrl = ts.URL
  // above line throws const baseUrl already defined error
  </code></pre>