Which method is best (more idomatic) for testing non-empty strings (in Go)?
if len(mystring) > 0 { }
Or:
if mystring != \"\"
Assuming that empty spaces and all leading and trailing white spaces should be removed:
import "strings" if len(strings.TrimSpace(s)) == 0 { ... }
Because : len("") // is 0 len(" ") // one empty space is 1 len(" ") // two empty spaces is 2
len("") // is 0
len(" ") // one empty space is 1
len(" ") // two empty spaces is 2