From 228c96fcea97034952ce60630b5ef78eb0a1dc8a Mon Sep 17 00:00:00 2001 From: Julio Lopez <1953782+julio-lopez@users.noreply.github.com> Date: Wed, 8 Nov 2023 05:46:11 -0800 Subject: [PATCH] Address io/ioutil deprecation (#354) --- internal/adapter/fs/fs.go | 3 +-- internal/adapter/lsp/server.go | 6 +++--- internal/cli/cmd/new.go | 4 ++-- 3 files changed, 6 insertions(+), 7 deletions(-) diff --git a/internal/adapter/fs/fs.go b/internal/adapter/fs/fs.go index 4f718d8..fe1c4a9 100644 --- a/internal/adapter/fs/fs.go +++ b/internal/adapter/fs/fs.go @@ -1,7 +1,6 @@ package fs import ( - "io/ioutil" "os" "path/filepath" "strings" @@ -114,7 +113,7 @@ func (fs *FileStorage) IsDescendantOf(dir string, path string) (bool, error) { } func (fs *FileStorage) Read(path string) ([]byte, error) { - return ioutil.ReadFile(path) + return os.ReadFile(path) } func (fs *FileStorage) Write(path string, content []byte) error { diff --git a/internal/adapter/lsp/server.go b/internal/adapter/lsp/server.go index f9b2942..b77acb3 100644 --- a/internal/adapter/lsp/server.go +++ b/internal/adapter/lsp/server.go @@ -3,7 +3,7 @@ package lsp import ( "encoding/json" "fmt" - "io/ioutil" + "os" "path/filepath" "strings" "time" @@ -209,7 +209,7 @@ func NewServer(opts ServerOpts) *Server { handler.CompletionItemResolve = func(context *glsp.Context, params *protocol.CompletionItem) (*protocol.CompletionItem, error) { if path, ok := params.Data.(string); ok { - content, err := ioutil.ReadFile(path) + content, err := os.ReadFile(path) if err != nil { return params, err } @@ -250,7 +250,7 @@ func NewServer(opts ServerOpts) *Server { } path = fs.Canonical(path) - contents, err := ioutil.ReadFile(path) + contents, err := os.ReadFile(path) if err != nil { return nil, err } diff --git a/internal/cli/cmd/new.go b/internal/cli/cmd/new.go index b889094..033b99d 100644 --- a/internal/cli/cmd/new.go +++ b/internal/cli/cmd/new.go @@ -3,7 +3,7 @@ package cmd import ( "errors" "fmt" - "io/ioutil" + "io" "os" "path/filepath" "time" @@ -36,7 +36,7 @@ func (cmd *New) Run(container *cli.Container) error { var content []byte if cmd.Interactive { - content, err = ioutil.ReadAll(os.Stdin) + content, err = io.ReadAll(os.Stdin) if err != nil { return err }