From f487c9409c20e753035dfc58befe888409ce14a9 Mon Sep 17 00:00:00 2001 From: Shulhan Date: Fri, 8 Jan 2021 14:23:10 +0700 Subject: 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. --- lib/sql/client.go | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'lib/sql') 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 } -- cgit v1.3-6-g1900