ioutil.ReadFile is deprecated, use os.ReadFile instead
76 Expect(err).NotTo(HaveOccurred())
77 Expect(string(fileContents)).To(Equal("some-file-contents"))
78
79 fileContents, err = ioutil.ReadFile(filepath.Join(extractionDest, "nonempty-dir", "file-in-dir")) 80 Expect(err).NotTo(HaveOccurred())
81 Expect(string(fileContents)).To(Equal("file-in-dir-contents"))
82
ioutil.ReadFile is deprecated, use os.ReadFile instead
72 })
73
74 extractionTest := func() {
75 fileContents, err := ioutil.ReadFile(filepath.Join(extractionDest, "some-file")) 76 Expect(err).NotTo(HaveOccurred())
77 Expect(string(fileContents)).To(Equal("some-file-contents"))
78
ioutil.ReadAll is deprecated, use io.ReadAll instead
65 }
66
67 if fileInfo.Mode()&os.ModeSymlink != 0 {
68 linkName, err := ioutil.ReadAll(input)69 if err != nil {
70 return err
71 }
ioutil.ReadFile is deprecated, use os.ReadFile instead
76 Expect(err).NotTo(HaveOccurred())
77 Expect(string(fileContents)).To(Equal("some-file-contents"))
78
79 fileContents, err = ioutil.ReadFile(filepath.Join(extractionDest, "nonempty-dir", "file-in-dir")) 80 Expect(err).NotTo(HaveOccurred())
81 Expect(string(fileContents)).To(Equal("file-in-dir-contents"))
82
ioutil.ReadFile is deprecated, use os.ReadFile instead
72 })
73
74 extractionTest := func() {
75 fileContents, err := ioutil.ReadFile(filepath.Join(extractionDest, "some-file")) 76 Expect(err).NotTo(HaveOccurred())
77 Expect(string(fileContents)).To(Equal("some-file-contents"))
78
ioutil.ReadAll is deprecated, use io.ReadAll instead
92 Expect(header.Name).To(Equal("inner-dir/some-file"))
93 Expect(header.FileInfo().IsDir()).To(BeFalse())
94
95 contents, err := ioutil.ReadAll(reader) 96 Expect(err).NotTo(HaveOccurred())
97 Expect(string(contents)).To(Equal("sup"))
98
ioutil.ReadFile is deprecated, use os.ReadFile instead
68
69 tgzfs.Extract(buffer, dest)
70
71 Expect(ioutil.ReadFile(filepath.Join(dest, "inner-dir", "some-file"))).To(Equal([]byte("sup"))) 72
73 Expect(os.Readlink(filepath.Join(dest, "inner-dir", "some-symlink"))).To(Equal("some-file"))
74 })
ioutil.ReadFile is deprecated, use os.ReadFile instead
86 // can't really assert access time...
87 Expect(stat.ModTime()).To(Equal(time.Unix(98765, 0)))
88
89 fileContents, err = ioutil.ReadFile(filepath.Join(extractionDest, "nonempty-dir", "file-in-dir")) 90 Expect(err).NotTo(HaveOccurred())
91 Expect(string(fileContents)).To(Equal("file-in-dir-contents"))
92
ioutil.ReadFile is deprecated, use os.ReadFile instead
77 extractionTest := func() {
78 someFile := filepath.Join(extractionDest, "some-file")
79
80 fileContents, err := ioutil.ReadFile(someFile) 81 Expect(err).NotTo(HaveOccurred())
82 Expect(string(fileContents)).To(Equal("some-file-contents"))
83
ioutil.ReadAll is deprecated, use io.ReadAll instead
89 Expect(header.Name).To(Equal("inner-dir/some-file"))
90 Expect(header.FileInfo().IsDir()).To(BeFalse())
91
92 contents, err := ioutil.ReadAll(reader) 93 Expect(err).NotTo(HaveOccurred())
94 Expect(string(contents)).To(Equal("sup"))
95
ioutil.ReadFile is deprecated, use os.ReadFile instead
68
69 tarfs.Extract(buffer, dest)
70
71 Expect(ioutil.ReadFile(filepath.Join(dest, "inner-dir", "some-file"))).To(Equal([]byte("sup"))) 72
73 Expect(os.Readlink(filepath.Join(dest, "inner-dir", "some-symlink"))).To(Equal("some-file"))
74 })
Description
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.
Bad practice
ioutil.ReadAll(r)
ioutil.ReadFile(filename)
ioutil.ReadDir(dirname)
// ...
Recommended
io.ReadAll(r)
os.ReadFile(filename)
os.ReadDir(dirname)
// ...