Skip to content
Node: !s.trim()github.com/sahilkhaire/gox/str

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) bool

Compare: 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) == ""

← Back to str package overview

MIT Licensed · Built for Node.js developers moving to Go