This is useful for environments where the angular app is served directly from golang. For example, using github.com/julienschmidt/httprouter
and having angular build in frontend/dist
directory
router := httprouter.New()
// All your router config here [...]
router.NotFound = http.FileServer(http.Dir("./frontend/dist"))
router.RedirectFixedPath = false
router.RedirectTrailingSlash = false
http.ListenAndServe(":8080", router)
First we need to build angular app watching for file changes: ng build -w
Then we can use bra to reload changes in golang backend
$ go get github.com/Unknwon/bra
$ bin/bra init
$ vim .bra.toml # adapt default options to fit your environment
$ bin/bra run