通过处理模板来改变语言的奇怪行为


Hello!

I'm learning Go language now and trying to port some simple WEB code (Laravel 4). Everything was well, until I tried to reproduce Blade templates into text templates. I found that Go can load my CSS and JavaScript files only from the catalog with a name "bootstrap" only.

Here is my catalog tree which I tried to use:

start-catalog
  bootstrap (link to bootstrap-3.3.1)
      bootstrap-3.3.1
    css
      bootstrap.min.css
    js
      bootstrap.min.js
  jquery
    jquery (link to jquery-2.1.1.min.js) 
    jsquery-2.1.1.min.js
  go_prg.go

Here are my templates:

base_js.tmpl

{{define "base_js"}}
      {{template "login_1"}}

      <script src = "/bootstrap/js/jquery"></script>
      <script src = "/bootstrap/js/bootstrap.min.js"></script>
{{end}}

base_header.tmpl

{{define "base_header"}} <head> <title>PAGE TITLE</title> <meta name = "viewport" content = "width=device-width, initial-scale=1.0"> <meta charset="utf-8"> <link href = "/bootstrap/css/bootstrap.min.css" rel = "stylesheet"> </head> {{end}}

If the catalog name differs from "bootstrap" Go language or Firefox can't load files from the templates above: bootstrap.min.css, bootstrap.min.js, jquery.
If I use not the link but the catalog name directly "bootstrap-3.3.1" than Go or Firefox can't load.
If all required files are moved under "bootstrap" I'm getting the results I expected (exactly the same as in Laravel 4).

To launch go language code the command go run go_prg.go was used.
Environment: Ubuntu 14.04, go-1.3.3, Firefox 31.

Who's wrong: Go language, Firefox or me?

Any help will be highly appreciated!

The problem described was caused by

http.Handle("/bootstrap/", http.StripPrefix("/bootstrap/", http.FileServer(http.Dir("bootstrap"))))

before any template was handled. It allowed access files under the directory 'bootstrap' only.

The problem was fixed by changing to http.Handle( , http.StripPrefix(, http.FileServer(http.Dir(".")))) and adding to pathes for CSS and JavaScript files. Like so

/bootstrap/js/jquery">.