Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fmt bumps last modified time even when no changes were made #1631

Closed
d-honeybadger opened this issue Jul 27, 2023 · 0 comments · Fixed by #1637
Closed

fmt bumps last modified time even when no changes were made #1631

d-honeybadger opened this issue Jul 27, 2023 · 0 comments · Fixed by #1637

Comments

@d-honeybadger
Copy link

d-honeybadger commented Jul 27, 2023

Describe the bug
swag fmt touches go files in the directory regardless of whether any changes were made in each of those files.
This minor detail comes to bite anyone who uses live-update build tools (e.g. observed with Tilt): if you want to automatically run swag fmt on changes to go files, this bumps lastmodified time, which then triggers another swag fmt, which ...

To Reproduce

  1. run swag fmt to make sure all comments are properly formatted
  2. note the last modified time of the files:
> ls -l
...
-rw-------  1 d-honeybadger d-honeybadger 17928 Jul 27 15:33 main.go
  1. Without making any changes to main.go, run swag fmt again
  2. Note that the last modified time got updated, even though this time no formatting changes were necessary:
> ls -l
...
-rw-------  1 d-honeybadger d-honeybadger 17928 Jul 27 15:35 main.go

Expected behavior
When no changes are made to a file, swag fmt should leave it as-is, without replacing/touching

Your swag version
e.g. 1.8.12

Your go version
e.g. 1.20.5

Desktop (please complete the following information):

  • OS: Ubuntu
  • Version: 20.04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant