aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStefan Majewsky <stefan.majewsky@sap.com>2023-10-25 15:54:11 +0200
committerGitHub <noreply@github.com>2023-10-25 15:54:11 +0200
commitd51753b8a70daba25c8bfff1b99ab6551e3f9dde (patch)
treeab0ff39b23534fae74b9347f1b81c42318ef39fd
parent8ed9ced09964a0f70ffcadd0aa8d25c7bc339352 (diff)
parentb8ad9b9e0c456d7b71ca4dd17bb08f46b1dbd5ca (diff)
downloadgofu-d51753b8a70daba25c8bfff1b99ab6551e3f9dde.tar.gz
Merge pull request #12 from SuperSandro2000/ioutil
Remove deprecated ioutil
-rw-r--r--internal/prompt/cloud.go5
-rw-r--r--internal/prompt/git.go11
-rw-r--r--internal/rtree/index.go5
-rw-r--r--internal/rtree/shared_test.go3
4 files changed, 10 insertions, 14 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 ""
}
diff --git a/internal/rtree/index.go b/internal/rtree/index.go
index 3a351a3..efc3c1f 100644
--- a/internal/rtree/index.go
+++ b/internal/rtree/index.go
@@ -21,7 +21,6 @@ package rtree
import (
"errors"
"fmt"
- "io/ioutil"
"os"
"path"
"path/filepath"
@@ -41,7 +40,7 @@ type Index struct {
// ReadIndex reads the index file.
func ReadIndex() (*Index, []error) {
//read contents of index file
- buf, err := ioutil.ReadFile(IndexPath)
+ buf, err := os.ReadFile(IndexPath)
if err != nil {
if os.IsNotExist(err) {
return &Index{Repos: nil}, nil
@@ -102,7 +101,7 @@ func (i *Index) Write() error {
if err != nil {
return err
}
- err = ioutil.WriteFile(IndexPath, buf, 0644)
+ err = os.WriteFile(IndexPath, buf, 0644)
if err != nil {
return err
}
diff --git a/internal/rtree/shared_test.go b/internal/rtree/shared_test.go
index bd8c238..2869c3c 100644
--- a/internal/rtree/shared_test.go
+++ b/internal/rtree/shared_test.go
@@ -23,7 +23,6 @@ import (
"errors"
"fmt"
"io"
- "io/ioutil"
"os"
"os/exec"
"path/filepath"
@@ -113,7 +112,7 @@ func (test Test) Run(t *testing.T) {
if err != nil {
t.Fatal(err.Error())
}
- actualIdxStr, err := ioutil.ReadFile(IndexPath)
+ actualIdxStr, err := os.ReadFile(IndexPath)
if err != nil {
t.Fatalf("%s: could not read index from %s: %s", t.Name(), IndexPath, err.Error())
}