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

refactor: move from io/ioutil to io and os packages #7207

Closed
wants to merge 1 commit into from
Closed

refactor: move from io/ioutil to io and os packages #7207

wants to merge 1 commit into from

Conversation

Juneezee
Copy link
Contributor

The io/ioutil package has been deprecated in Go 1.16 (See https://golang.org/doc/go1.16#ioutil). Since this project has been upgraded to Go 1.17 in #7029, this PR replaces the existing io/ioutil functions with their new definitions in io and os packages.

Don't bother creating a PR until you've done this:

  • Run make pre-commit -B to fix codegen, lint, and commit message problems.

Create your PR as a draft.

  • Your PR needs to pass the required checks before it can be approved. If the check is not required (e.g. E2E tests) it
    does not need to pass.
  • Once required tests have passed, you can make it "Ready for review".
  • Say how how you tested your changes. If you changed the UI, attach screenshots.

Tips:

  • If changes were requested, and you've made them, then dismiss the review to get it looked at again.
  • Add you organization to USERS.md if you like.
  • You can ask for help!

The io/ioutil package has been deprecated as of Go 1.16, see
https://golang.org/doc/go1.16#ioutil. This commit replaces the existing
io/ioutil functions with their new definitions in io and os packages.

Signed-off-by: Eng Zer Jun <engzerjun@gmail.com>
@Juneezee Juneezee marked this pull request as ready for review November 11, 2021 12:20
Copy link
Member

@simster7 simster7 left a comment

Choose a reason for hiding this comment

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

It seems like so from the patch notes, but it's never explicitly mentioned: is the functionality between the ioutil and the io/os functions guaranteed to be the same?

@Juneezee
Copy link
Contributor Author

It seems like so from the patch notes, but it's never explicitly mentioned: is the functionality between the ioutil and the io/os functions guaranteed to be the same?

@simster7 Hi, thanks for reviewing this PR. Yes, functions in iouti and the io/os functions have the same functionality. These changes should not affect the end users experience as well.

There is one small difference between ioutil.ReadDir and os.ReadDir. The os.ReadDir is proposed (golang/go#41467) for lightweight directory reading, hence it returns []os.DirEntry instead of []os.FileInfo.

Copy link
Member

@simster7 simster7 left a comment

Choose a reason for hiding this comment

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

This LGTM, but will let @alexec take a look before merging

@alexec
Copy link
Contributor

alexec commented Nov 12, 2021

I'm sorry, I don't think we should accept this PR. The reason is that we often have to back port fixes, and changes to package imports will create a lot of work for anyone doing the back-porting. I don't think that cost outweighs the benefits.

@alexec alexec closed this Nov 16, 2021
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 this pull request may close these issues.

3 participants