aboutsummaryrefslogtreecommitdiff
path: root/lib/sql/client.go
diff options
context:
space:
mode:
authorShulhan <m.shulhan@gmail.com>2021-01-08 14:23:10 +0700
committerShulhan <m.shulhan@gmail.com>2021-01-08 14:23:10 +0700
commitf487c9409c20e753035dfc58befe888409ce14a9 (patch)
tree53c20f962f20a3e8c797d1d635ed508e9f1acc70 /lib/sql/client.go
parent961b6864858220d89568185af25fff35b1d03113 (diff)
downloadpakakeh.go-f487c9409c20e753035dfc58befe888409ce14a9.tar.xz
sql: check nil on Migrate parameter "fs" using reflect.IsNil
If we pass nil pointer of type to fs, the if condition will not true and this cause panic because fs is not nil.
Diffstat (limited to 'lib/sql/client.go')
-rw-r--r--lib/sql/client.go4
1 files changed, 3 insertions, 1 deletions
diff --git a/lib/sql/client.go b/lib/sql/client.go
index 3ab7ccef..eb559e2e 100644
--- a/lib/sql/client.go
+++ b/lib/sql/client.go
@@ -16,6 +16,8 @@ import (
"path/filepath"
"sort"
"strings"
+
+ "github.com/shuLhan/share/lib/reflect"
)
const (
@@ -102,7 +104,7 @@ func (cl *Client) FetchTableNames() (tableNames []string, err error) {
// SQL file name that has been executed and the timestamp.
//
func (cl *Client) Migrate(fs http.FileSystem) (err error) {
- if fs == nil {
+ if reflect.IsNil(fs) {
if len(cl.MigrationDir) == 0 {
return nil
}