Closed ianic closed 2 years ago
Watch command now watches everything inside the project directory.
I've tried fixing the issue through current watcher library with provided Ignore
and Remove
methods but that proved to be a challenge due to the way library works internally and combining that option with additional filters.
I've also tried to do it through the regex filters by adding a filter that matches all go files except main.go
but that also proved to be a challenge due to Go not supporting this feature as there's no way to do it in O(n) complexity which is current library guarantee.
I also haven't managed to find decent replacement. The closest one is fsnotify but it doesn't support recursively adding folders which is necessary in our case.
Having tried all this, the solution I decided to implement is just to check if the file that triggered the change is main.go
and ignoring the event in that case. So currently, during each deploy watch event will be triggered twice - first event will deploy the changes and then another event will be generated since deploy process created new main.go
but that second event will be ignored by the Mantil.
Does that mean that I can't have main.go file anywhere in my project and count on watch to catch up changes in it? For example /internal/my-packkage/main.go
That's a valid point. I've changed the implementation to instead ignore everything in build/
directory located in the root of the project, that's a cleaner solution anyway.
In 0.2.5 when I start watch after the first change it is constantly detecting changes. We are creating build folder now, and there we create some Go files which are immediately triggering a new change. I fix it now by watching only api folder.