404 page not found - Go rendering css file

前端 未结 1 1728
挽巷
挽巷 2020-12-04 00:16

I\'m currently working in Go. I created a web server on my local machine. I followed the instruction on this page Rendering CSS in a Go Web Application but I\'m still gettin

相关标签:
1条回答
  • 2020-12-04 01:00

    Since you don't specify full path for the css folder just a relative one, whether your css files are found depends on the folder you run your application from (the working directory, this is what relative paths are resolved to).

    For example if you start your application from your src with go run server/server.go it will work. If you start it from your src/server folder with go run server.go, it will not work. Also if you create a native executable from your app which is put into the bin folder and you start that from the bin folder, this also won't work because the css folder is not in the bin folder.

    Either start it with go run server/server.go from the src folder, or copy the css folder to your bin folder and start the executable from the bin folder and it should work (but in this case you also have to copy other static files like html templates).

    0 讨论(0)
提交回复
热议问题