Can not load css and .js file with template engine

Hey guys,
I want to load an HTML document with a template engine in Golang. I have these files:
-myGoProgram as a binary file

and in my goBinary file, try to load css like this:
http.Handle("…/static/", http.StripPrefix("…/static/", http.FileServer(http.Dir(“static”))))
log.Fatal(http.ListenAndServe(":8080", router))

and inside HTML document I try to load CSS and app.js like this:

when I try to load an HTML document without Go binary file everything would load correctly. but when try to load like this:
CSS and js file won’t load

please help me to fix this issue. thank you

thanks to dear Peter, a member of gophers slack, to help solve this problem.
I should use that router I defined to handle all routes, in this case, I used go-chi.

with this change now everything works correctly:

fs := http.FileServer(http.Dir("static"))
router.Handle("/static/*", http.StripPrefix("/static/", fs))

this StackOverFlow topic also helped me:

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.