2015-03-11 09:49
浏览 114


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: 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

图片转代码服务由CSDN问答提供 功能建议

我有一个GO项目,该项目的UI由html编写。 在HTML文件中,我已经编写了javascript,并且可以安装GO并成功加载UI。

问题是,当我将这些javascript代码移动到外部文件并包括它时:。 我只能构建GO,但是在加载UI时,它会显示错误404 Not Found,即“ myscripts.js”文件。 奇怪的是它的错误标头上: 远程地址: 请求网址: http: //localhost:8080/subscribe/myscripts.js 请求方法:GET 状态代码:404未找到

请帮助,我找不到任何答案 这个

  • 写回答
  • 关注问题
  • 收藏
  • 邀请回答

1条回答 默认 最新

  • dongsheng8664 2015-03-11 09:55

    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.

    打赏 评论