io/ioutil
package usage GO-C400151 continue
52 }
53
54 msg, err := ioutil.ReadAll(reader)55 if err != nil {
56 return 0, err
57 }
16 }
17
18 for _, prefix := range devPrefixes {
19 files, err := ioutil.ReadDir(prefix)20 if err != nil {
21 continue
22 }
62 lines = lines[len(lines)-h.maxSize:]
63 }
64 h.lines = append(lines, "")
65 return ioutil.WriteFile(h.path, []byte(strings.Join(h.lines, "\n")), 0600)66}
67
68func (h *History) override(str string) {
31 // If it doesn't exist, check if we can create a file with the name
32 if os.IsNotExist(err) {
33 data = []byte{}
34 if err := ioutil.WriteFile(path, data, 0600); err != nil {35 return nil, fmtError(err)
36 }
37 } else {
26 }
27
28 // Read history file
29 data, err := ioutil.ReadFile(path)30 if err != nil {
31 // If it doesn't exist, check if we can create a file with the name
32 if os.IsNotExist(err) {
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)
// ...