Go Auto-Recompile and Reload Server on file change

后端 未结 9 907
清酒与你
清酒与你 2020-12-15 22:14

I know AppEngine does this, but I\'m not coding for it.

I tried using Guard from Ruby world, to listen on changes on .go files, and execut

9条回答
  •  天涯浪人
    2020-12-15 22:42

    You can use nodemon for this. Simply create a nodemon.json file containing your configuration, files to watch, files to ignore, and command to execute when a file changes. Something like this configuration.

    nodemon.json

    {
      "watch": ["*"],
      "ext": "go graphql",
      "ignore": ["*gen*.go"],
      "exec": "go run scripts/gqlgen.go && (killall -9 server || true ) && go run ./server/server.go"
    }
    

    You do require nodejs for this to work.
    But its far better then any other tool I've used so far that are go specific.

提交回复
热议问题