A string builder that has similar capabilities as the one from C#. The goal is to have a straightforward API that lets you work with strings easily.
To install the package, call:
go get -u github.com/linkdotnet/golang-stringbuilder
Next import the package:
import ( "github.com/linkdotnet/golang-stringbuilder" )
The API derives from the C# StringBuilder
. You can easily append strings or single runes.
func main() {
sb := Text.StringBuilder{}
sb.Append("Hello")
sb.Append(" ")
sb.Append("World")
fmt.Println(sb.ToString())
}
Also more advanced use cases where you want to insert an arbitrary word at an arbitrary position are possible.
sb := NewStringBuilderFromString("Hello World")
sb.Insert(5, " my dear")
output := sb.ToString() // Hello my dear World