Text

package module
v0.1.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 21, 2022 License: MIT Imports: 1 Imported by: 1

README

golang-stringbuilder

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.

Install

To install the package, call:

go get -u github.com/linkdotnet/golang-stringbuilder 

Usage

package sample

import (
	"fmt"

	Text "github.com/linkdotnet/golang-stringbuilder"
)

func main() {
	sb := Text.StringBuilder{}
	sb.Append("Hello")
	sb.Append(" ")
	sb.Append("World")
	fmt.Println(sb.ToString())
}

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type StringBuilder

type StringBuilder struct {
	// contains filtered or unexported fields
}

func NewFromString

func NewFromString(text string) *StringBuilder

Creates a new instance of the StringBuilder with a preallocated text

func NewStringBuilder

func NewStringBuilder(initialCapacity int) *StringBuilder

Creates a new instance of the StringBuilder with preallocated array

func (*StringBuilder) Append

func (s *StringBuilder) Append(text string)

Appends a text to the StringBuilder instance

func (*StringBuilder) AppendLine

func (s *StringBuilder) AppendLine(text string)

Appends a text and a new line character to the StringBuilder instance

func (*StringBuilder) AppendRune

func (s *StringBuilder) AppendRune(char rune)

Appends a single character to the StringBuilder instance

func (*StringBuilder) Insert

func (s *StringBuilder) Insert(index int, text string) error

func (*StringBuilder) Len

func (s *StringBuilder) Len() int

Returns the current length of the represented string

func (*StringBuilder) Remove

func (s *StringBuilder) Remove(start int, length int) error

func (*StringBuilder) ToString

func (s *StringBuilder) ToString() string

Returns the represented string

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL