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 does not preserve file permissions #1635

Closed
hohobilly opened this issue Aug 2, 2023 · 0 comments · Fixed by #1636
Closed

fmt does not preserve file permissions #1635

hohobilly opened this issue Aug 2, 2023 · 0 comments · Fixed by #1636

Comments

@hohobilly
Copy link
Contributor

Describe the bug
When running swag fmt, the formatter updates the permission of the files.
This minor difference usually don't cause any issues, only in some cases like if someone is running swag fmt with root permission. The owner is changed the root. With group read permission gone, the user cannot access the formatted file.
Overall, I believe fmt should preserve the permission from the original file as a default behavior.

To Reproduce

  1. Check the file permission before formatting
> ls -l
-rw-r--r--  1 user user  7755 Aug 2 9:42 main.go
  1. run swag fmt
  2. Check the file permission again
> ls -l
-rw------- 1 user user  7755 Aug 2 9:43 main.go 
// If running with root, because user is change, user don't have permission to read the file anymore

Expected behavior
fmt should preserve the permission from the original file.

Your swag version
v1.8.12

Your go version
e.g. 1.12.0

Desktop (please complete the following information):

  • OS: macOS
  • Version: Ventura 13.0
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