Go Auto-Recompile and Reload Server on file change

后端 未结 9 917
清酒与你
清酒与你 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:46

    I've recently discovered a reflex tool. It's fast and works like a charm. It is very similar to nodemon (from nodejs world) and guard (from ruby world).

    Most of the time I'm using it similar to below:

    reflex -d none -s -R vendor. -r \.go$ -- go run cmd/server/main.go

    But it maybe more convenient to have it's options in a file like .reflex, with contents like this:

    -d none -s -R vendor. -r \.go$

    So then you just run it like this

    reflex $(cat .reflex) -- go run cmd/server/main.go

    You can do same thing to "hot reload" tests:

    reflex $(cat .reflex) -- go test ./... -v

    There is also a config option where you can specify a number of commands you run same time, but I don't really use it.

提交回复
热议问题