Logo

Programming-Idioms

History of Idiom 110 > diff from v2 to v3

Edit summary for version 3 by :
New Go implementation by user [programming-idioms.org]

Version 2

2015-12-29, 22:25:37

Version 3

2015-12-29, 22:33:37

Idiom #110 Check if string is blank

Set boolean blank to true if string s is empty, or null, or contains only whitespace ; false otherwise.

Idiom #110 Check if string is blank

Set boolean blank to true if string s is empty, or null, or contains only whitespace ; false otherwise.

Imports
import strings"
Code
blank := strings.TrimSpace(s) == ""
Comments bubble
Trim s, then check if empty.
Doc URL
https://golang.org/pkg/strings/#TrimSpace
Demo URL
http://play.golang.org/p/1dvSNEObOs