File change detection is unreliable when coding with IntelliJ/GoLand
When using IntelliJ/Goland, after a few changes, no file changes are detected anymore. Even outside of the IDE. Looks like it breaks silently.
When a change is made with VSCode, the watch code receives this event:
CHANGE notify.Write: "/Users/dgageot/go/src/github.com/GoogleCloudPlatform/skaffold/examples/getting-started/main.go"
Same change in IntelliJ:
CHANGE notify.Rename: "/Users/dgageot/go/src/github.com/GoogleCloudPlatform/skaffold/examples/getting-started/main.go"
Or sometimes:
CHANGE notify.Rename|notify.Remove: "/Users/dgageot/go/src/github.com/GoogleCloudPlatform/skaffold/examples/getting-started/main.go"
It looks like IntelliJ doesn't do straight writes to file and that messes with the file watcher.
OK. So the library we are using to track file changes removes a file from the watch list if this file is removed/renamed. IntelliJ does rename the file when it's saved. We need to find a better way of using the library or a better library.
I've tried 3 fsnotify libraries. None of them support deleting and then recreating files. One way to fix that is to watch parent folders for file creation. It'll make the code way more complicated
This is also happening for PHPStorm as reported on twitter
https://twitter.com/gortron/status/980822889728479232
I think this may be related to a setting that is called "Use safe write (save changes to a temporary file first)". I haven't run into this issue since turning that setting off.
I might be related to something different altogether I used this solution from the git side and it worked like magic https://stackoverflow.com/questions/1580596/how-do-i-make-git-ignore-file-mode-chmod-changes git config core.fileMode false