silenceper / gowatch

🚀 gowatch is a command line tool that builds and (re)starts your go project everytime you save a Go or template file.
MIT License
838 stars 99 forks source link

Multiple build problem on git branches #40

Open kabessao opened 3 years ago

kabessao commented 3 years ago

The project I'm working on has many branches that at some point are going to be merged to master, and whenever I switch branches with the application running it starts building for each modified file.

Ex.: if I change to a branch that has 100 files different from master, the application will build 100 times.

It would be nice if the application could wait, like, 1 second for files to change to build.

silenceper commented 3 years ago

Thanks for the feedback,I will confirm this issue later.

silenceper commented 3 years ago

@kabessao Are you using the latest version?

A one-second delay has been processed in the project,Is it that the delay is not enough.

https://github.com/silenceper/gowatch/blob/f7b7964cc6d5b41313282c5bb3feb4c452e7334c/gowatch.go#L58-L66

https://github.com/silenceper/gowatch/blob/f7b7964cc6d5b41313282c5bb3feb4c452e7334c/gowatch.go#L110-L118

kabessao commented 3 years ago

I belive I am, I'm using this command to install gowatch:

go get github.com/silenceper/gowatch

and inside the docker it says 1.5 on gowatch -v

and just stashing files and applying the stash later on the repo makes it build multiple times. There were 5 go files and it built 5 times one after the other.

here is a print of the log (had to redact some parts to prevent me getting into problems) : image

kabessao commented 3 years ago

I've just cross checked the lines that the log shows with your code on master and indeed it does not match, and checking the code inside the docker image confirms it.

That means this command is not getting the latest version:

go get github.com/silenceper/gowatch
silenceper commented 3 years ago

try this:

go get -u github.com/silenceper/gowatch
kabessao commented 3 years ago

Same result, it gave me the older version.

I don't know if this helps since I'm new to golang, but this is the docker image we're using golang:1.16-alphine3.13

silenceper commented 3 years ago

Maybe you can also try to download https://github.com/silenceper/gowatch/releases/tag/v1.5.1 from here, and install the binary files directly