diff options
| author | Sandro Jäckel <sandro.jaeckel@gmail.com> | 2023-10-25 15:39:58 +0200 |
|---|---|---|
| committer | Sandro Jäckel <sandro.jaeckel@gmail.com> | 2023-10-25 15:39:58 +0200 |
| commit | b8ad9b9e0c456d7b71ca4dd17bb08f46b1dbd5ca (patch) | |
| tree | ab0ff39b23534fae74b9347f1b81c42318ef39fd /internal/prompt | |
| parent | 8ed9ced09964a0f70ffcadd0aa8d25c7bc339352 (diff) | |
| download | gofu-b8ad9b9e0c456d7b71ca4dd17bb08f46b1dbd5ca.tar.gz | |
Remove deprecated ioutil
Diffstat (limited to 'internal/prompt')
| -rw-r--r-- | internal/prompt/cloud.go | 5 | ||||
| -rw-r--r-- | internal/prompt/git.go | 11 |
2 files changed, 7 insertions, 9 deletions
diff --git a/internal/prompt/cloud.go b/internal/prompt/cloud.go index 42a2c39..ce3160f 100644 --- a/internal/prompt/cloud.go +++ b/internal/prompt/cloud.go @@ -19,7 +19,6 @@ package prompt import ( - "io/ioutil" "os" "os/exec" "path/filepath" @@ -47,7 +46,7 @@ func getKubernetesField() string { return "" } - namespaceBytes, err := ioutil.ReadFile(filepath.Join(os.Getenv("HOME"), ".kubectl-namespace")) + namespaceBytes, err := os.ReadFile(filepath.Join(os.Getenv("HOME"), ".kubectl-namespace")) namespace := strings.TrimSpace(string(namespaceBytes)) if err != nil { if !os.IsNotExist(err) { @@ -60,7 +59,7 @@ func getKubernetesField() string { } func getKubernetesContext(configPath string) string { - buf, err := ioutil.ReadFile(configPath) + buf, err := os.ReadFile(configPath) if err != nil { //non-existence is acceptable, just make the caller continue with the next configPath if !os.IsNotExist(err) { diff --git a/internal/prompt/git.go b/internal/prompt/git.go index 8393c3e..6f0cf1d 100644 --- a/internal/prompt/git.go +++ b/internal/prompt/git.go @@ -20,7 +20,6 @@ package prompt import ( "fmt" - "io/ioutil" "os" "path/filepath" "strings" @@ -31,7 +30,7 @@ type gitRepo struct { GitDir string } -//Returns two empty strings if `path` is not inside a Git repo. +// Returns two empty strings if `path` is not inside a Git repo. func findRepo(path string) (*gitRepo, error) { //find .git directory or file gitEntry := filepath.Join(path, ".git") @@ -54,7 +53,7 @@ func findRepo(path string) (*gitRepo, error) { } //.git is a file (e.g. for submodules) - it contains a line like "gitdir: path/to/gitdir" - bytes, err := ioutil.ReadFile(gitEntry) + bytes, err := os.ReadFile(gitEntry) if err != nil { return nil, err } @@ -76,7 +75,7 @@ func getRepoStatusField(repo *gitRepo) string { return "" } - bytes, err := ioutil.ReadFile(filepath.Join(repo.GitDir, "HEAD")) + bytes, err := os.ReadFile(filepath.Join(repo.GitDir, "HEAD")) if err != nil { handleError(err) return withType("git", withColor("1;41", "unknown")) @@ -94,7 +93,7 @@ func getRepoStatusField(repo *gitRepo) string { refSpecDisplay = strings.TrimPrefix(refSpecDisplay, "heads/") //read file corresponding to refspec to find commit ID - bytes, err = ioutil.ReadFile(filepath.Join(repo.GitDir, refSpec)) + bytes, err = os.ReadFile(filepath.Join(repo.GitDir, refSpec)) commitID := strings.TrimSpace(string(bytes)) if err != nil { if os.IsNotExist(err) { @@ -112,7 +111,7 @@ func getRepoStatusField(repo *gitRepo) string { } func tryReadFromPackedRefs(repo *gitRepo, refSpec string) string { - bytes, err := ioutil.ReadFile(filepath.Join(repo.GitDir, "packed-refs")) + bytes, err := os.ReadFile(filepath.Join(repo.GitDir, "packed-refs")) if err != nil { return "" } |
