-
Notifications
You must be signed in to change notification settings - Fork 18k
proposal: net/url: URL.Clone, Values.Clone #73450
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
Comments
Related Issues
(Emoji vote if this was helpful or unhelpful; more detailed feedback welcome in this discussion.) |
@seankhliao I'm probably missing something, but shouldn't |
please read #41733 I suppose someone can do |
This is really two proposals in one.
|
Is this thought incomplete?
Instead of referencing other issues and pulling people's focus off this one could we summarize what context we expect readers to come away with after reading a linked issue? I'm assuming in this case the context is that
Agreed. I can clearly see the use case for a However, I don't personally see the value in a |
reading past proposals is critical to not rehash past discussions. please do that, especially since this is the previous proposal, but with evidence backing up why the current situation is deficient. given the widespread use of cloning in existing codebases (see the search results), I don't think it's necessary to list the use cases. it's clearly something people need and do, but inefficiently. |
I did read the linked issue. That's why I asked what context you're referring to so we can all be on the same page. Specifically around
With all due respect, and I do truly mean that as someone that's grateful that you submitted this proposal, this perspective isn't helpful to anyone or any proposal and comes off a bit paternalistic. The search results provide data but that data is not a substitute for defining and writing down the use cases so future readers can understand the motivation for this proposal. Especially when there are open questions around the still unclear behavior of |
The confusion with UserInfo is what lead to the current situation, how exactly it works isn't really relevant beyond that it should be unambiguously safe and efficient with the proposed api. I don't see how knowing what people use it for will change the evaluation of the proposal. In fact, I think it's a distraction from the proposal, as it's not to make a new capability possible. The motivation is as the original post, driven by real world usage data: the current api (or lack thereof) leads to suboptimal performance and ergonomics in a large number of existing programs when manipulating URLs. Since safely modifying URLs is not a pattern to discourage, it should be made better. |
If the confusion is what led us to the current situation then the confusion should be documented in the proposal so that, again, we're all on the same page. The proposal lists an API but does not discuss the implementation or note the
Programming languages are built for people. Knowing how people use the features in a programming language and, more importantly, writing it down is how we can ensure the work done via a proposal is the right work and positively impacts the community.
The data is limited to code on GitHub that matches a specific pattern which is not representative of all URL cloning usage or all Go code. Granted, no data set can truly be representative of every user but I digress. The data tells us that some users are cloning URLs but it does not tell us whether there's a critical performance issue in these code paths or whether users even care about having a new API for cloning URLs. This is the importance of gathering user feedback rather than relying strictly on "the data" to make decisions. I've seen past Go proposals rely strictly on data to the detriment of the community.
I do have a question born out of curiosity. How was it calculated that the data collected represents an eighth of users? Perhaps I'm simply missing something. Lastly, I fear that I know what's next based on these discussions. This is mainly for the lurkers here but I have to say something because I'm tired of seeing the same behavior play out again and again. Someone will come in and say that these comments are "off topic" or "distracting" and pull up some code of conduct or rules to wield as a threat of banning if the discussions do not cease. Outside of my question above I have nothing further to add on this proposal since it's clear that the original poster is not interested in answering the questions I've asked. Thank you again for this proposal and good luck with it! |
Proposal Details
Proposed addition:
Motivation
Right now, there's no clear way to safely copy a net/url.URL: #38351
As the linked issue states, it is safe to do
url2 := *url1
, but it's not clear to users.For example a rough (String/Parse are common names, so guestimate with
u
) search shows:That is a significant portion (1/8) of users paying the additional cost of serialization/deserialization for what could be a simple copy.
The parse variant also means having to deal with an error return variable that should always be nil.
The safe and efficient way of doing it should be:
go/src/net/http/clone.go
Line 41 in 49860cf
For Values, because of its nested
map[string][]string
structure, a deep clone is necessary (and not possible with . While it is less common than a url's Parse(u.String()), I think it should be available:cc @neild @rsc
The text was updated successfully, but these errors were encountered: