GithubHelp home page GithubHelp logo

linkdotnet / golang-stringbuilder Goto Github PK

View Code? Open in Web Editor NEW
3.0 1.0 0.0 100 KB

A string builder that has similar capabilities as the one from C#.

License: MIT License

Go 100.00%
go golang string stringbuilder

golang-stringbuilder's Introduction

Header

Welcome

Hey lot, my name is Steven and I am a .NET developer based in Zurich. Welcome to my public page. I am most likely interested in new technologies. If you want to know more just check out the links down below.

I also have a blog here and if you are interested in the source code of it, here you go.

Social

Linkedin Badge Stackoverflow Badge Github Bade Blog Blade

Github

Metrics

golang-stringbuilder's People

Contributors

dependabot[bot] avatar g41797 avatar linkdotnet avatar varunu28 avatar

Stargazers

 avatar  avatar  avatar

Watchers

 avatar

golang-stringbuilder's Issues

Add `Trim`, `TrimStart` and `TrimEnd` to the StringBuilder

Trimming whitespaces is a typical operation for strings.

Possible API surface:

func (s *StringBuilder)  Trim(chars ...rune) *StringBuilder {}
func (s *StringBuilder)  TrimStart(chars ...rune) *StringBuilder {}
func (s *StringBuilder)  TrimEnd(chars ...rune) *StringBuilder {}

If chars is empty we trim whitespace from the StringBuilder.

v1

This should be a container for things we want to tackle for v1. If we can’t find other topics, we can merge v1 into main and release it.

Upgrade go.mod to `1.21`

With the v1 release we can bump the go-version to 1.21.
This change has to be also made inside the workflow files

Epic: Make String Builder thread safe

This is a multi-step effort to make string builder thread-safe and allow users to use it in a multi-threaded environment.

Keeping this open for discussion and narrow down on what particular tasks need be accomplished in order to convert the current implementation to a thread-safe implementation.

Add new method SetRuneAt

I am going to save stringbuilders within Pool and reuse them

func (s *StringBuilder) SetRuneAt(pos int, val rune) error 

error for wrong pos (don't expect grow)

Also for reusing:

func (s *StringBuilder) Rewind()
func (s *StringBuilder) Skip(n count) error

Feature Request: Make Append operation return *StringBuilder to facilitate chaining

Typical functionality of a builder function consists of chaining operation. The exisitng implementation of Append function can be modified to return *StringBuilder. This will facilitate chaining operation and end up resulting in cleaner code.

For example current sample code is as below:

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

With the updated feature, above code will look like:

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

I will be happy to add a POC implementation for this feature and can extend the implementation to other Append functions in future.

Let me know what you think @linkdotnet

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.