-
Notifications
You must be signed in to change notification settings - Fork 18k
proposal: io/ioutil: rename to io/fileio or similar #19660
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
Comments
io.ReadFull / ioutil.ReadAll pair is especially frustrating. |
To take the logic a bit further with respect to removing chattiness, how about (or: why not?) one step further: Sounding them out: There may be good arguments for |
Looks like this will be a huge problem, same as |
I agree with @cristaloleg: this is absolutely a problem in practice.
|
Should this proposal be closed because of #42026 ? |
Yes, thanks. |
I find myself constantly needing to look up the documentation for
io
andio/ioutil
to figure out which package contains the thing I want to use.The root of the problem is that
ioutil
isn't a coherent abstraction boundary. The suffixutil
doesn't add any information — if a package has no utility, it should not exist! — and the remaining information in the package name doesn't distinguish it fromio
. (See also the "Bad package names" section of https://blog.golang.org/package-names.)From what I can tell, the main purpose of separating out
ioutil
is to reduce the dependencies ofio
: specifically, the dependencies onbytes
,os
, andsort
.In a potential Go 2, I propose to resolve those dependencies by refactoring the
ioutil
package as follows:Move
Discard
,NopCloser
, andReadAll
into packageio
:NopCloser
has no dependencies.Discard
depends onsync
, whichio
already depends on.ReadAll
uses abytes.Buffer
internally, but doesn't actually need very much of its API; it can be rewritten easily to avoid that dependency.Move
ReadDir
,ReadFile
,TempDir
,TempFile
, andWriteFile
to a new package,io/fileio
.File
suffix:fileio.Read
instead ofioutil.ReadFile
.The text was updated successfully, but these errors were encountered: