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

Make output modes configurable #60

Merged
merged 1 commit into from
Aug 22, 2016
Merged

Make output modes configurable #60

merged 1 commit into from
Aug 22, 2016

Conversation

@yugui yugui force-pushed the feature/gazel_2 branch from eef9965 to 7241aa5 Compare August 8, 2016 10:56
@yugui yugui force-pushed the feature/gazel_3 branch from e556b33 to 61d30e9 Compare August 8, 2016 11:02
@yugui yugui force-pushed the feature/gazel_2 branch 3 times, most recently from 6907367 to 7ae0cfe Compare August 17, 2016 06:44
@yugui yugui changed the base branch from feature/gazel_2 to master August 18, 2016 01:28
if err != nil {
return err
}
defer os.Remove(f.Name())
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In my experience, worrying about the error from the defer is overkill, and creates complexity without much gain.

I agree.

Actually in my experience it was necessary to correctly deal with disk full in the target file system, temporary network issue or something. But as you said, worrying about that does not add much value in this specific case of short-living process unlike my experience.

I would have written (instead of line 31-49):

defer os.Remove(f.Name())
defer f.Close()
if _, err := f.Write(bzl.Format(file)); err != nil {
return err
}

Thank you for your suggestion. Fixed.
But I added Sync because Close used to also imply Sync in the original code.

@yugui
Copy link
Contributor Author

yugui commented Aug 18, 2016

@pmbethe09 Could you take another look at this PR?

}
defer os.Remove(f.Name())
defer f.Close()
if _, err = f.Write(bzl.Format(file)); err != nil {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

use := instead of = whenever possible, like here.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

@pmbethe09
Copy link
Contributor

LGTM with a couple of nitpicks.

Added "fix" and "diff" modes
@yugui yugui merged commit ad1cad2 into master Aug 22, 2016
@yugui
Copy link
Contributor Author

yugui commented Aug 22, 2016

Thank you for your review.

@yugui yugui deleted the feature/gazel_3 branch August 22, 2016 04:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants