Remove ioutil.

This commit is contained in:
Nuno Cruces 2022-05-13 12:19:46 +01:00
parent a9649cc64e
commit cf33a53ba0

View file

@ -3,7 +3,6 @@ package zenutil
import (
"bytes"
"context"
"io/ioutil"
"os"
"os/exec"
"path/filepath"
@ -21,12 +20,12 @@ func Run(ctx context.Context, script string, data interface{}) ([]byte, error) {
if Command {
// Try to use syscall.Exec, fallback to exec.Command.
if path, err := exec.LookPath("osascript"); err != nil {
} else if t, err := ioutil.TempFile("", ""); err != nil {
} else if t, err := os.CreateTemp("", ""); err != nil {
} else if err := os.Remove(t.Name()); err != nil {
} else if _, err := t.Write(buf.Bytes()); err != nil {
} else if _, err := t.Seek(0, 0); err != nil {
} else if err := syscall.Dup2(int(t.Fd()), syscall.Stdin); err != nil {
} else if err := os.Stderr.Close(); err != nil {
} else if err := syscall.Dup2(int(t.Fd()), syscall.Stdin); err != nil {
} else {
syscall.Exec(path, []string{"osascript", "-l", "JavaScript"}, nil)
}
@ -54,7 +53,7 @@ func RunProgress(ctx context.Context, max int, data Progress) (dlg *progressDial
return nil, err
}
t, err := ioutil.TempDir("", "")
t, err := os.MkdirTemp("", "")
if err != nil {
return nil, err
}