Camel
Overview
Converts kebab-case or snake_case strings to camelCase — common when mapping JSON field names to Go struct tags.
If you are coming from Node.js, the closest pattern is camelCase(s).
Signature
go
func Camel(s string) stringCompare: Node.js · Standard Go · gox
js
_.camelCase('foo_bar');go
// Manual rune walk or regexp replace
s = "fooBar"go
import "github.com/sahilkhaire/gox/str"
s := str.Camel("foo_bar")Example
go
import "github.com/sahilkhaire/gox/str"
s := str.Camel("foo_bar")Tips
Import github.com/sahilkhaire/gox/str and call Camel directly. See the comparison below for the standard library equivalent.
Standard library alternative
Use the standard library directly:
go
// Manual rune walk or regexp replace
s = "fooBar"