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

Remove readFile() and reverseSlice() in favour of stdlib #671

Merged
merged 8 commits into from
Jan 24, 2025

Conversation

udf2457
Copy link
Contributor

@udf2457 udf2457 commented Jan 22, 2025

propose removing readFile() from updater.go as it appears to essentially be a re-implementation of stdlib's os.ReadFile

Also found a "hidden" re-implementation of os.ReadFile in metadata.go, so changed that to os.ReadFile too.

Also found the re-implementation of os.Readfile in cli/tuf/cmd/root.go, so changed that to os.ReadFile too.

Also found a re-implementation of os.ReadFile in cli/tuf-client/cmd/root.go where it appears completely unused ?

Also reverseSlice() in metadata/updater/updater.go seems to be a reimplementation of stdlib's slices.Reverse() so removed that too.

Phew... I think that's all of them. 😆

remove readFile() as it appears to essentially be a re-implementation of stdlib's os.ReadFile

Signed-off-by: udf2457 <[email protected]>
Another instance of re-implementing os.ReadFile.  This one does not even appear to be used by the cli code.

Signed-off-by: udf2457 <[email protected]>
Reference os.Readfile instead of the re-implementation

Signed-off-by: udf2457 <[email protected]>
Remove ReadFile re-implementation

Signed-off-by: udf2457 <[email protected]>
@udf2457 udf2457 changed the title Remove readFile() from updater.go Remove readFile() from updater.go (and ReadFile from cli examples) Jan 22, 2025
Don't reinvent the wheel, use stdlib os.ReadFile 😉 

Signed-off-by: udf2457 <[email protected]>
@udf2457 udf2457 changed the title Remove readFile() from updater.go (and ReadFile from cli examples) Remove readFile() from updater.go, metadata.go (and ReadFile from cli examples) Jan 22, 2025
Remive the reimplementation of stdlib slices.Reverse()

Signed-off-by: udf2457 <[email protected]>
@udf2457 udf2457 changed the title Remove readFile() from updater.go, metadata.go (and ReadFile from cli examples) Remove readFile() and reverseSlice() from updater.go, metadata.go (and ReadFile from cli examples) Jan 22, 2025
@udf2457 udf2457 changed the title Remove readFile() and reverseSlice() from updater.go, metadata.go (and ReadFile from cli examples) Remove readFile() and reverseSlice() in favour of stdlib Jan 23, 2025
@udf2457
Copy link
Contributor Author

udf2457 commented Jan 23, 2025

I see the test failed on examples/cli/tuf-client/cmd/root.go:21:2: "io" imported and not used.

Easily fixed, I'll remove the io from that file.

remove un-necessary io import

Signed-off-by: udf2457 <[email protected]>
@udf2457
Copy link
Contributor Author

udf2457 commented Jan 23, 2025

Can you try re-running the test, io is gone now from root.go.

Apologies for missing that !

Remove io import

Signed-off-by: udf2457 <[email protected]>
Copy link
Member

@kommendorkapten kommendorkapten left a comment

Choose a reason for hiding this comment

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

This is great, thank you!

@mnm678 mnm678 merged commit 423f3ab into theupdateframework:master Jan 24, 2025
23 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

3 participants