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?
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:
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 addUnwriteByte,UnwriteRuneand perhapsUnwriteStringfunctions tostrings.Builder?