To check if the array is empty follow these steps:

Check with the builtin len() function, for example, len(slice) <= 0. If the array is empty, skip the for a loop.

r := whatever()
if len(r) > 0 {
   // do what you want
}

BY Best Interview Question ON 11 Mar 2020