Skip to content

How to check if a string is empty in Go

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:

if len(s) > { // do something with string }
Code language: Go (go)

Option 2 – Compare against blank:

if s != "" { // do something with string }
Code language: Go (go)

See also  cross browser alpha css
Tags:
Subscribe
Notify of
guest
0 Comments
Inline Feedbacks
View all comments
0
Would love your thoughts, please comment.x
()
x