If you need to check if a string
is empty in Go, then there are two possible ways to immediately verify this:
Option 1 – Compare the length:
1
2
3
|
if len(s) > 0 {
// do something with string
}
|
Option 2 – Compare against blank:
1
2
3
|
if s != "" {
// do something with string
}
|