io/ioutil
package usage GO-C400117 id := vars["id"]
18
19 // read the file into memory with ioutil.ReadFile
20 file, err := ioutil.ReadFile(id)21
22 // if an error occurs, return a 404 not found response
23 if err != nil {
io/ioutil
package, like most things with util in the name, has turned out to
be a poorly defined and complex to understand the collection of things.
In a series of a few changes, the entire ioutil package will become deprecated starting from Go 1.16.
Existing code using ioutil will continue to work; ioutil will consist of simple wrappers to new functions which reside in the io and os packages.
ioutil.ReadAll(r)
ioutil.ReadFile(filename)
ioutil.ReadDir(dirname)
// ...
io.ReadAll(r)
os.ReadFile(filename)
os.ReadDir(dirname)
// ...