Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save isalgueiro/1621eb1c67267338a5fb302f3c93ddbe to your computer and use it in GitHub Desktop.
Save isalgueiro/1621eb1c67267338a5fb302f3c93ddbe to your computer and use it in GitHub Desktop.
setup a development environment with hot reloading code changes

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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment