pkg/pidfile: remove PIDFile type and cleanup#44266
Merged
thaJeztah merged 4 commits intomoby:masterfrom Oct 15, 2022
Merged
Conversation
samuelkarp
approved these changes
Oct 9, 2022
corhere
approved these changes
Oct 13, 2022
…nconvert Signed-off-by: Sebastiaan van Stijn <[email protected]>
It's ok to ignore if the file doesn't exist, or if the file doesn't have a PID in it, but we should produce an error if the file exists, but we're unable to read it for other reasons. Signed-off-by: Sebastiaan van Stijn <[email protected]>
Use bytes.TrimSpace instead of using the strings package, which is more performant, and allows us to skip the intermediate variable. Also combined some "if" statements to reduce cyclomatic complexity. Signed-off-by: Sebastiaan van Stijn <[email protected]>
8d51f26 to
049148b
Compare
This type felt really redundant; `pidfile.New()` takes the path of the file to create as an argument, so this is already known. The only thing the PIDFile type provided was a `Remove()` method, which was just calling `os.Remove()` on the path of the file. Signed-off-by: Sebastiaan van Stijn <[email protected]>
049148b to
43d6eb7
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
pkg/pidfile: pkg/pidfile: use strconv instead of fmt.Sprintf(), and unconvert
pkg/pidfile: don't ignore all errors when reading file
It's ok to ignore if the file doesn't exist, or if the file doesn't
have a PID in it, but we should produce an error if the file exists,
but we're unable to read it for other reasons.
pkg/pidfile: reduce cyclomatic complexity, and small optimisation
Use bytes.TrimSpace instead of using the strings package, which is
more performant, and allows us to skip the intermediate variable.
Also combined some "if" statements to reduce cyclomatic complexity.
pkg/pidfile: remove PIDFile type
This type felt really redundant;
pidfile.New()takes the path of the file tocreate as an argument, so this is already known. The only thing the PIDFile
type provided was a
Remove()method, which was just callingos.Remove()onthe path of the file.