IsBlank
Overview
IsBlank reports whether s is empty or only whitespace.
If you are coming from Node.js, the closest pattern is !s.trim().
Signature
go
func IsBlank(s string) boolCompare: Node.js · Standard Go · gox
js
!s.trim();go
blank := strings.TrimSpace(s) == ""go
import "github.com/sahilkhaire/gox/str"
if str.IsBlank(input) { /* empty */ }Example
go
import "github.com/sahilkhaire/gox/str"
if str.IsBlank(input) { /* empty */ }Tips
Import github.com/sahilkhaire/gox/str and call IsBlank directly. See the comparison below for the standard library equivalent.
Standard library alternative
Use the standard library directly:
go
blank := strings.TrimSpace(s) == ""