Replace deprecated ioutil pkg with os & io

As of Go 1.16, the same functionality is now provided by package io or
package os, and those implementations should be preferred in new code.

So replacing all usage of ioutil pkg with io & os.
This commit is contained in:
Abhinav Nair
2022-06-26 16:57:29 +08:00
parent 7b4a8df991
commit baec8ed6b6
35 changed files with 109 additions and 139 deletions
+4 -4
View File
@@ -3,15 +3,15 @@ package github
import (
"context"
"fmt"
"golang.org/x/oauth2"
"io"
"io/ioutil"
"net/http"
nurl "net/url"
"os"
"path"
"strings"
"golang.org/x/oauth2"
"github.com/golang-migrate/migrate/v4/source"
"github.com/google/go-github/v39/github"
)
@@ -194,7 +194,7 @@ func (g *Github) ReadUp(version uint) (r io.ReadCloser, identifier string, err e
if err != nil {
return nil, "", err
}
return ioutil.NopCloser(strings.NewReader(r)), m.Identifier, nil
return io.NopCloser(strings.NewReader(r)), m.Identifier, nil
}
}
return nil, "", &os.PathError{Op: fmt.Sprintf("read version %v", version), Path: g.config.Path, Err: os.ErrNotExist}
@@ -220,7 +220,7 @@ func (g *Github) ReadDown(version uint) (r io.ReadCloser, identifier string, err
if err != nil {
return nil, "", err
}
return ioutil.NopCloser(strings.NewReader(r)), m.Identifier, nil
return io.NopCloser(strings.NewReader(r)), m.Identifier, nil
}
}
return nil, "", &os.PathError{Op: fmt.Sprintf("read version %v", version), Path: g.config.Path, Err: os.ErrNotExist}
+2 -2
View File
@@ -3,7 +3,7 @@ package github
import (
"bytes"
"fmt"
"io/ioutil"
"os"
"testing"
st "github.com/golang-migrate/migrate/v4/source/testing"
@@ -13,7 +13,7 @@ import (
var GithubTestSecret = "" // username:token
func init() {
secrets, err := ioutil.ReadFile(".github_test_secrets")
secrets, err := os.ReadFile(".github_test_secrets")
if err == nil {
GithubTestSecret = string(bytes.TrimSpace(secrets)[:])
}