Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
kardolus
GitHub Repository: kardolus/chatgpt-cli
Path: blob/main/vendor/github.com/onsi/gomega/internal/gutil/using_ioutil.go
2893 views
1
//go:build !go1.16
2
// +build !go1.16
3
4
// Package gutil is a replacement for ioutil, which should not be used in new
5
// code as of Go 1.16. With Go 1.15 and lower, this implementation
6
// uses the ioutil functions, meaning that although Gomega is not officially
7
// supported on these versions, it is still likely to work.
8
package gutil
9
10
import (
11
"io"
12
"io/ioutil"
13
)
14
15
func NopCloser(r io.Reader) io.ReadCloser {
16
return ioutil.NopCloser(r)
17
}
18
19
func ReadAll(r io.Reader) ([]byte, error) {
20
return ioutil.ReadAll(r)
21
}
22
23
func ReadDir(dirname string) ([]string, error) {
24
files, err := ioutil.ReadDir(dirname)
25
if err != nil {
26
return nil, err
27
}
28
29
var names []string
30
for _, file := range files {
31
names = append(names, file.Name())
32
}
33
34
return names, nil
35
}
36
37
func ReadFile(filename string) ([]byte, error) {
38
return ioutil.ReadFile(filename)
39
}
40
41
func MkdirTemp(dir, pattern string) (string, error) {
42
return ioutil.TempDir(dir, pattern)
43
}
44
45
func WriteFile(filename string, data []byte) error {
46
return ioutil.WriteFile(filename, data, 0644)
47
}
48
49