Ruby's string manipulation magic brought to Golang
Why?
"What was the biggest surprise you encountered rolling out Go?" I knew the answer instantly: Although we expected C++ programmers to see Go as an alternative, instead most Go programmers come from languages like Python and Ruby. Robert Pike, Less is exponentially more
stringutil makes all the string manipulation methods from ruby accessible in go.
go get https://github.com/wallclockbuilder/stringutil
import "stringutil" "https://github.com/wallclockbuilder/stringutil"
I want to remove the trailing space from the end of a string.
This is what Go forces me to do:
strings.TrimRightFunc(s, unicode.IsSpace)
This is the simple version from Ruby:
stringutil.Rstrip(s)
I prefer the Ruby version.
package main
import "github.com/wallclockbuilder/stringutil"
func main() {
stringutil.Capitalize("abcde") #=> "ABCDE"
stringutil.Reverse("stressed") #=> "desserts"
stringutil.Swapcase("Hello") #=> "hELLO"
}
go doc
style documentation for this package is available online at http://godoc.org/github.com/wallclockbuilder/stringutil
git checkout -b my-new-feature
)git commit -am 'Add some feature'
)git push origin my-new-feature
)