1.

How do I check if an array is empty in Golang?

Answer»

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
}



Discussion

No Comment Found