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

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

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

rising622 opened this issue Jan 8, 2021 · 3 comments
Labels
FrozenDueToAge NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.
Milestone

Comments

@rising622
Copy link

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

why not return dst.String() directly

@mvdan
Copy link
Member

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
@mvdan mvdan added the NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. label Jan 8, 2021
@ianlancetaylor
Copy link
Contributor

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

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
@golang golang locked and limited conversation to collaborators May 4, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
FrozenDueToAge NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.
Projects
None yet
Development

No branches or pull requests

5 participants