title: Src attribute in golang templates
body: <p>When executing template on golang server, I got an issue that src attribute in html file searches for importing javascript file not in the root location (server folder), but below the handled url. So, requesting <code>src='/dir/file.js'</code> having current location like <code>http://localhost:8080/handled/</code> will make GET request for <code>http://localhost:8080/handled/dir/file.js</code>. </p>
  
  <pre><code>package main
  
  import ("net/http"; "html/template")
  
  var templates = template.Must(template.ParseFiles("././dir/file.html"))
  
  type Page struct {
    Title string
    Body  []byte
  }
  
  func testHandler(w http.ResponseWriter, r *http.Request) {
    page := Page{"handled", nil}
  
    err := templates.ExecuteTemplate(w, "file.html", p)
    if err != nil {
      http.Error(w, err.Error(), http.StatusInternalServerError)
    }
  }
  
  func main() {
    http.HandleFunc("/handled/", testHandler)
    http.ListenAndServe(":8080", nil)
  }
  </code></pre>
  
  <p>So, the template file.html contains the following line:</p>
  
  <pre><code>&lt;!-- file.html
  javascript placed right inside template file is working,
  but I didnt managed to get to work src insertation --&gt;
  &lt;script src="file.js"&gt;&lt;/script&gt;
  </code></pre>
  
  <p>...the file.js sharing the same directory with file.html.
  I tried different file locations and various paths combinations. Seems like I'm doing it a wrong way.</p>