mirror of
https://github.com/hanzoai/migrate.git
synced 2026-09-30 22:55:10 +00:00
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:
@@ -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}
|
||||
|
||||
@@ -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)[:])
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user