0

I have a GO project which has UI written by html. In HTML file, I have written javascript, and I can install GO and load the UI successfully.

The problem is when I move those javascript code to an external file, and include it: . I only can build GO, but when load the UI, it has error 404 Not Found which is "myscripts.js" file. The weird thing is on its header of error: Remote Address:127.0.0.1:8080 Request URL:http://localhost:8080/subscribe/myscripts.js Request Method:GET Status Code:404 Not Found

Please help, I can't find any answer yet for this

Amir Koklan
  • 897
  • 2
  • 12
  • 32
  • I include by simply writing this line of code in HTML file: – Ryan Nguyen Mar 11 '15 at 09:53
  • If those html files are fragments in deeper folders ensure that the script path is relative based on the final page they are inject to and not the template itself – makeitmorehuman Mar 11 '15 at 09:54
  • possible duplicate of [Include js file in Go template](http://stackoverflow.com/questions/28899675/include-js-file-in-go-template) – Dave C Mar 11 '15 at 16:29

1 Answers1

3

That's normal if you only define handler for your endpoints.

You should add to your router the http.FileServer handler pointing to the directory that store your project files.

Additionally, think about the <base> that to define the root of your relative links, which will prevent errors such as path nesting.

Elwinar
  • 9,103
  • 32
  • 40