Use strings.NewReader() instead of bytes.NewReader() when source is a string

- Group imports
This commit is contained in:
Dale Hui
2018-11-05 22:50:08 -08:00
parent 231e7c9948
commit 435481bcec
4 changed files with 19 additions and 13 deletions
+4 -3
View File
@@ -1,7 +1,6 @@
package github
import (
"bytes"
"context"
"fmt"
"io"
@@ -10,7 +9,9 @@ import (
"os"
"path"
"strings"
)
import (
"github.com/golang-migrate/migrate/v4/source"
"github.com/google/go-github/github"
)
@@ -158,7 +159,7 @@ func (g *Github) ReadUp(version uint) (r io.ReadCloser, identifier string, err e
if err != nil {
return nil, "", err
}
return ioutil.NopCloser(bytes.NewReader([]byte(r))), m.Identifier, nil
return ioutil.NopCloser(strings.NewReader(r)), m.Identifier, nil
}
}
return nil, "", &os.PathError{fmt.Sprintf("read version %v", version), g.path, os.ErrNotExist}
@@ -175,7 +176,7 @@ func (g *Github) ReadDown(version uint) (r io.ReadCloser, identifier string, err
if err != nil {
return nil, "", err
}
return ioutil.NopCloser(bytes.NewReader([]byte(r))), m.Identifier, nil
return ioutil.NopCloser(strings.NewReader(r)), m.Identifier, nil
}
}
return nil, "", &os.PathError{fmt.Sprintf("read version %v", version), g.path, os.ErrNotExist}