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

Proposal: Upgrading examples from using io/util (once 1.17 ships) #343

Closed
selahaddinh opened this issue Jan 25, 2021 · 5 comments · Fixed by #374
Closed

Proposal: Upgrading examples from using io/util (once 1.17 ships) #343

selahaddinh opened this issue Jan 25, 2021 · 5 comments · Fixed by #374

Comments

@selahaddinh
Copy link

selahaddinh commented Jan 25, 2021

Hey everyone,
As you may know, there are talks of deprecating io/util for go v1.16.
More on this can be found:
golang/go#40025
go-critic/go-critic#1019
golang/go#42026

I think, upgrading the examples from using io/util would be beneficial for newcomers to learn the state-of-art practices.

@selahaddinh selahaddinh changed the title Proposal: Upgrading examples from using io/util to io/fs Proposal: Upgrading examples from using io/util Jan 25, 2021
@eliben
Copy link
Collaborator

eliben commented Jan 25, 2021

Sounds good, given that the replacements work on the current and previous version (e.g. if they go in right now, on versions 1.15 and 1.14 at least). Feel free to send a PR

@selahaddinh
Copy link
Author

I believe, this needs to wait version 1.17 then.

@selahaddinh
Copy link
Author

just leaving here for archive purpose, from https://tip.golang.org/doc/go1.16


Discard => io.Discard
NopCloser => io.NopCloser
ReadAll => io.ReadAll
ReadDir => os.ReadDir (note: returns a slice of os.DirEntry rather than a slice of fs.FileInfo)
ReadFile => os.ReadFile
TempDir => os.MkdirTemp
TempFile => os.CreateTemp
WriteFile => os.WriteFile```

@eliben
Copy link
Collaborator

eliben commented Feb 15, 2021

Go 1.17 will be released in August 2021. At that point we should be able to safely replace uses of ioutil with os, where applicable.

At this time, gobyexample uses the following functions from ioutil in examples:

  • WriteFile
  • ReadDir
  • ReadAll
  • TempFile
  • TempDir
  • ReadFile

@eliben eliben changed the title Proposal: Upgrading examples from using io/util Proposal: Upgrading examples from using io/util (once 1.17 ships) Feb 20, 2021
@eliben
Copy link
Collaborator

eliben commented Jun 1, 2021

Since we keep getting duplicate reports, I went ahead and created #374 which implements this - that PR will be updated and reviewed/landed once Go 1.17 ships in August 2021.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants