diff options
author | Bart <info@bartfokker.com> | 2023-07-16 10:14:22 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-07-16 17:14:22 +0900 |
commit | 3c09c77269d848f5e7dd8f350a90e8d7ed760845 (patch) | |
tree | cf418e344df526d58b6a3a7fc83bcc29d81d60f9 /src/history.go | |
parent | 547e101f1d6bf326d286bac0fb3272738a92a67f (diff) |
Fix deprecations of ioutil (#3370)
Diffstat (limited to 'src/history.go')
-rw-r--r-- | src/history.go | 9 |
1 files changed, 4 insertions, 5 deletions
diff --git a/src/history.go b/src/history.go index 45728d40..1e66c721 100644 --- a/src/history.go +++ b/src/history.go @@ -2,7 +2,6 @@ package fzf import ( "errors" - "io/ioutil" "os" "strings" ) @@ -26,12 +25,12 @@ func NewHistory(path string, maxSize int) (*History, error) { } // Read history file - data, err := ioutil.ReadFile(path) + data, err := os.ReadFile(path) if err != nil { // If it doesn't exist, check if we can create a file with the name if os.IsNotExist(err) { data = []byte{} - if err := ioutil.WriteFile(path, data, 0600); err != nil { + if err := os.WriteFile(path, data, 0600); err != nil { return nil, fmtError(err) } } else { @@ -62,11 +61,11 @@ func (h *History) append(line string) error { lines = lines[len(lines)-h.maxSize:] } h.lines = append(lines, "") - return ioutil.WriteFile(h.path, []byte(strings.Join(h.lines, "\n")), 0600) + return os.WriteFile(h.path, []byte(strings.Join(h.lines, "\n")), 0600) } func (h *History) override(str string) { - // You can update the history but they're not written to the file + // You can update the history, but they're not written to the file if h.cursor == len(h.lines)-1 { h.lines[h.cursor] = str } else if h.cursor < len(h.lines)-1 { |