diff options
| author | Shulhan <m.shulhan@gmail.com> | 2021-01-08 14:23:10 +0700 |
|---|---|---|
| committer | Shulhan <m.shulhan@gmail.com> | 2021-01-08 14:23:10 +0700 |
| commit | f487c9409c20e753035dfc58befe888409ce14a9 (patch) | |
| tree | 53c20f962f20a3e8c797d1d635ed508e9f1acc70 /lib/sql | |
| parent | 961b6864858220d89568185af25fff35b1d03113 (diff) | |
| download | pakakeh.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')
| -rw-r--r-- | lib/sql/client.go | 4 |
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 } |
