Logo

Programming-Idioms

History of Idiom 110 > diff from v3 to v4

Edit summary for version 4 by :
[Go] Fixed import

Version 3

2015-12-29, 22:33:37

Version 4

2016-01-06, 23:16:58

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