Skip to content

Commit

Permalink
Removes leftover references to ioutil
Browse files Browse the repository at this point in the history
  • Loading branch information
donatj committed Mar 20, 2024
1 parent 6a739b4 commit 95a0e5a
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions editor.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ package noteofcli

import (
"fmt"
"io/ioutil"
"io"
"log"
"os"
"os/exec"
Expand All @@ -14,7 +14,7 @@ var wsre = regexp.MustCompile("\\s")
func Edit(editor, text string) ([]byte, error) {
stat, _ := os.Stdin.Stat()
if (stat.Mode()&os.ModeCharDevice) == 0 || editor == "" {
return ioutil.ReadAll(os.Stdin)
return io.ReadAll(os.Stdin)
} else if editor != "" {
return ExecEditor(editor, text)
}
Expand All @@ -25,7 +25,7 @@ func Edit(editor, text string) ([]byte, error) {
func ExecEditor(editor, text string) ([]byte, error) {
parts := wsre.Split(editor, -1)

tmpfile, err := ioutil.TempFile("", "post")
tmpfile, err := os.CreateTemp("", "post")
tmpfile.WriteString(text)
tmpPath := tmpfile.Name()
tmpfile.Close()
Expand Down Expand Up @@ -54,7 +54,7 @@ func ExecEditor(editor, text string) ([]byte, error) {

log.Println()

body, err := ioutil.ReadFile(tmpPath)
body, err := os.ReadFile(tmpPath)
if err != nil {
return []byte{}, err
}
Expand Down

0 comments on commit 95a0e5a

Please sign in to comment.