Automatic Reloading in Go(Nodemon)
Automatically restarting the server always help to us increase our efficiency, That is the reason we can do our job faster via automation so in this article we will learn how to restart the go-lang project,
There is multiple ways to restart the go-lang server after saving the file, but i will talk here one of the best process manager Nodemon, Yes nodemon is not only for JS project via nodemon you can restart any of the projects by making use of the --exec
flag.
I am assuming you have already installed Nodemon in your system.
Now, we can run the web server using Nodemon by running the following command:
nodemon --exec go run main.go --signal SIGTERM
After changing some code then save.
If you want to configure Nodemon, create the configuration file nodemon.json
in the project’s root directory. A full sample config file is available here.
That’s it for this time! I hope you enjoyed this post. As always, I welcome questions, notes, comments and requests for posts on topics you’d like to read. See you next time! Happy Coding !!!!!