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

Snake

Overview ​

Snake converts to snake_case.

If you are coming from Node.js, the closest pattern is snake_case(s).

Signature ​

go
func Snake(s string) string

Compare: Node.js · Standard Go · gox ​

js
_.snakeCase('FooBar');
go
s = strings.ToLower(strings.ReplaceAll(name, " ", "_"))
go
import "github.com/sahilkhaire/gox/str"

s := str.Snake("FooBar")

Example ​

go
import "github.com/sahilkhaire/gox/str"

s := str.Snake("FooBar")

Tips ​

Import github.com/sahilkhaire/gox/str and call Snake directly. See the comparison below for the standard library equivalent.

Standard library alternative ​

Use the standard library directly:

go
s = strings.ToLower(strings.ReplaceAll(name, " ", "_"))

← Back to str package overview

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