Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: remove ioutil usage #46

Merged
merged 1 commit into from
Mar 31, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 3 additions & 4 deletions basher.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ package basher
import (
"fmt"
"io"
"io/ioutil"
"log"
"os"
"os/exec"
Expand Down Expand Up @@ -165,12 +164,12 @@ func (c *Context) CopyEnv() {
}

// Source adds a shell script to the Context environment. The loader argument can be nil
// which means it will use ioutil.Readfile and load from disk, but it exists so you
// which means it will use os.Readfile and load from disk, but it exists so you
// can use the Asset function produced by go-bindata when including script files in
// your Go binary. Calls to Source adds files to the environment in order.
func (c *Context) Source(filepath string, loader func(string) ([]byte, error)) error {
if loader == nil {
loader = ioutil.ReadFile
loader = os.ReadFile
}
data, err := loader(filepath)
if err != nil {
Expand Down Expand Up @@ -218,7 +217,7 @@ func (c *Context) HandleFuncs(args []string) bool {
}

func (c *Context) buildEnvfile() (string, error) {
file, err := ioutil.TempFile(os.TempDir(), "bashenv.")
file, err := os.CreateTemp(os.TempDir(), "bashenv.")
if err != nil {
return "", err
}
Expand Down