Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

net/url: why not return dst.String() directly? #43587

Open
rising622 opened this issue Jan 8, 2021 · 3 comments
Open

net/url: why not return dst.String() directly? #43587

rising622 opened this issue Jan 8, 2021 · 3 comments
Milestone

Comments

@rising622
Copy link

@rising622 rising622 commented Jan 8, 2021

return "/" + strings.TrimPrefix(dst.String(), "/")

why not return dst.String() directly

@mvdan
Copy link
Member

@mvdan mvdan commented Jan 8, 2021

Most likely because you don't know if dst has a slash as a prefix?

The code doesn't seem terribly efficient in the case where the slash already exists, but I don't know if that actually matters.

@mvdan mvdan changed the title why not return dst.String() directly? net/url: why not return dst.String() directly? Jan 8, 2021
@ianlancetaylor
Copy link
Contributor

@ianlancetaylor ianlancetaylor commented Jan 8, 2021

It's for historical reasons. See https://golang.org/cl/264817.

But we can clean it up. Sent https://golang.org/cl/282673.

@gopherbot
Copy link

@gopherbot gopherbot commented Jan 8, 2021

Change https://golang.org/cl/282673 mentions this issue: net/url: avoid string concatenation in resolvePath

@odeke-em odeke-em added this to the Go1.17 milestone Jan 10, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
5 participants
You can’t perform that action at this time.