A package for manipulate strings
$ go get github.com/mrignacio1231/strtools
Add following line in your *.go
file:
import "github.com/mrignacio1231/strtools"
If you are unhappy to use long strtools
, you can do something like this:
import (
str "github.com/mrignacio1231/strtools"
)
Go code with Substr() function
strtools.Substr("Hello World", 0, 4) // Output: Hello
// Support for negative index
strtools.Substr("Hello World", -5, 11) // Output: World
Go code with IsString() function
strtools.IsString("I'm a string") // Output: true
strtools.IsString(12.4) // Output: false
Generate a random string with Random() function
strtools.Random(6) // Return a random string