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

Replaced deprecated ioutil package #136

Merged
merged 1 commit into from
May 9, 2022
Merged
Show file tree
Hide file tree
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
4 changes: 2 additions & 2 deletions client/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import (
"encoding/json"
"errors"
"fmt"
"io/ioutil"
"os"
"path/filepath"
"regexp"
"strings"
Expand Down Expand Up @@ -325,7 +325,7 @@ func publicKeyAuthMethod(kp string) (ssh.AuthMethod, error) {
if err != nil {
return nil, err
}
key, err := ioutil.ReadFile(keyPath)
key, err := os.ReadFile(keyPath)
if err != nil {
return nil, err
}
Expand Down
3 changes: 1 addition & 2 deletions cmd/backup_keys.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import (
"archive/tar"
"fmt"
"io"
"io/ioutil"
"os"
"path"
"path/filepath"
Expand Down Expand Up @@ -80,7 +79,7 @@ func validateDirectory(path string) error {
return fmt.Errorf("%v is not a directory, but it should be", path)
}

files, err := ioutil.ReadDir(path)
files, err := os.ReadDir(path)
if err != nil {
return err
}
Expand Down
3 changes: 1 addition & 2 deletions fs/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ import (
"fmt"
"io"
"io/fs"
"ioutil"
"os"

charmfs "github.com/charmbracelet/charm/fs"
Expand All @@ -24,7 +23,7 @@ func main() {
}
// Write a file
data := []byte("some data")
err = ioutil.WriteFile("/tmp/data", data, 0644)
err = os.WriteFile("/tmp/data", data, 0644)
if err != nil {
panic(err)
}
Expand Down
3 changes: 1 addition & 2 deletions kv/kv.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ package kv
import (
"fmt"
"io"
"io/ioutil"
"log"
"math"
"os"
Expand Down Expand Up @@ -153,7 +152,7 @@ func (kv *KV) Set(key []byte, value []byte) error {
// SetReader is a convenience method to set the value for a key to the data
// read from the provided io.Reader.
func (kv *KV) SetReader(key []byte, value io.Reader) error {
v, err := ioutil.ReadAll(value)
v, err := io.ReadAll(value)
if err != nil {
return err
}
Expand Down
5 changes: 2 additions & 3 deletions server/http.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import (
"fmt"
"io"
"io/fs"
"io/ioutil"
"log"
"net/http"
"strconv"
Expand Down Expand Up @@ -203,7 +202,7 @@ func (s *HTTPServer) handlePostUser(w http.ResponseWriter, r *http.Request) {
return
}
u := &charm.User{}
body, err := ioutil.ReadAll(r.Body)
body, err := io.ReadAll(r.Body)
if err != nil {
log.Printf("cannot read request body: %s", err)
s.renderError(w)
Expand All @@ -230,7 +229,7 @@ func (s *HTTPServer) handlePostUser(w http.ResponseWriter, r *http.Request) {
func (s *HTTPServer) handlePostEncryptKey(w http.ResponseWriter, r *http.Request) {
u := s.charmUserFromRequest(w, r)
ek := &charm.EncryptKey{}
body, err := ioutil.ReadAll(r.Body)
body, err := io.ReadAll(r.Body)
if err != nil {
log.Printf("cannot read request body: %s", err)
s.renderError(w)
Expand Down
6 changes: 3 additions & 3 deletions server/storage/local/storage_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ package localstorage

import (
"bytes"
"io"
"io/fs"
"io/ioutil"
"os"
"path/filepath"
"testing"
Expand Down Expand Up @@ -53,7 +53,7 @@ func TestPut(t *testing.T) {
t.Fatalf("expected file %s to be a regular file", path)
}

read, err := ioutil.ReadAll(file)
read, err := io.ReadAll(file)
if err != nil {
t.Fatalf("expected no error when reading file %s", path)
}
Expand Down Expand Up @@ -86,7 +86,7 @@ func TestPut(t *testing.T) {
t.Fatalf("expected file %s to be a regular file", path)
}

read, err := ioutil.ReadAll(file)
read, err := io.ReadAll(file)
if err != nil {
t.Fatalf("expected no error when reading file %s", path)
}
Expand Down