File tree Expand file tree Collapse file tree 2 files changed +13
-0
lines changed Expand file tree Collapse file tree 2 files changed +13
-0
lines changed Original file line number Diff line number Diff line change @@ -1629,6 +1629,9 @@ func Glob(pattern string) ([]string, error) {
1629
1629
1630
1630
// Empty empty()
1631
1631
func Empty (val interface {}) bool {
1632
+ if val == nil {
1633
+ return true
1634
+ }
1632
1635
v := reflect .ValueOf (val )
1633
1636
switch v .Kind () {
1634
1637
case reflect .String , reflect .Array :
Original file line number Diff line number Diff line change @@ -308,6 +308,16 @@ func TestVariable(t *testing.T) {
308
308
309
309
tIsNumeric = IsNumeric ("123456" )
310
310
equal (t , true , tIsNumeric )
311
+
312
+ equal (t , true , Empty (nil ))
313
+ equal (t , true , Empty (false ))
314
+ equal (t , true , Empty (0 ))
315
+ equal (t , true , Empty ("" ))
316
+ equal (t , true , Empty (0.0 ))
317
+ equal (t , true , Empty ([]int {}))
318
+ equal (t , true , Empty ([0 ]int {}))
319
+ equal (t , false , Empty ([1 ]int {}))
320
+ equal (t , true , Empty (map [int ]int {}))
311
321
}
312
322
313
323
func TestProgramExecution (t * testing.T ) {
You can’t perform that action at this time.
0 commit comments