Skip to content

strings: please add UnwriteByte to Builder #36038

@jech

Description

@jech

Go version 1.13.

There does not seem to be a way to remove data written to a strings.Builder.

I'm currently doing the following:

func pathUrl(p []string) string {
	var b []byte
	for _, s := range p {
		t := url.PathEscape(s)
		b = append(b, t...)
		b = append(b, '/')
	}
	return string(b[0 : len(b)-1])
}

The last line removes the trailing slash from the accumulated buffer. I don't see an obvious way of doing the same with a strings.Builder. Perhaps it would be a good idea to add UnwriteByte, UnwriteRune and perhaps UnwriteString functions to strings.Builder?

Metadata

Metadata

Assignees

No one assigned

    Labels

    FeatureRequestIssues asking for a new feature that does not need a proposal.FrozenDueToAgeNeedsInvestigationSomeone must examine and confirm this is a valid issue and not a duplicate of an existing one.

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions