-
Notifications
You must be signed in to change notification settings - Fork 17.5k
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
proposal: strings: add new functions to deprecate strings.{Trim/TrimRight/TrimLeft} to avoid mistakes #50399
Comments
I dont see how using I dont think Strip conveys a meaning that it is a cutset more or less then Trim so I dont think just advising to use Strip instead of Trim makes developers more or less likely to mistake the function as not using a cutset. |
@martisch I edit the issue again to focus on 1 suggestion. Thanks. |
Presumably if we do something in the strings package we would also it in the bytes package. |
This proposal has been added to the active column of the proposals project |
If we make a change here, we should also change the names to not use "left" and "right". We should use "prefix" and "suffix" instead. |
The open question is how often this comes up and the vet check (#46533, not implemented yet) wouldn't catch it for people. We have strings.IndexAny(s, chars) already. Maybe TrimAny We should probably also do TrimPrefixFunc instead of TrimLeftFunc, TrimRightFunc. It would be a good test of "go fix"-based inlining (does not exist yet) to migrate these. We might want to wait for a coherent migration story. |
Let's put this on hold until we have the migration story better understood, and then we can return to this. It seems worth doing with the names we chose, as a test of the migration tool if nothing else. |
Placed on hold. |
Hi, could we add new methods to solve the problem of
cutset
type in Strings.{Trim/TrimRight/TrimLeft}.Apparently, many gohpers misunderstood the this
cutset
type, and it cauese some bugs. And, there're several proposals for solving thecutset
type problem:I read through this proposals and see the conclusion is no change will be made.
This
cutset
problem affects many developers:In python,
str.{strip/rstrip/lstrip}('cutset')
method works the same as in gostrings.{Trim/TrimRight/TrimLeft}(s, "cutset")
. Maybe this signature is ok.If we:
//Deprecated
andgo:linkname
on strings.{Trim/TrimRight/TrimLeft}, we may make this clearercutset
as []rune, and use this methods to reimplement strings.{Trim/TrimRight/TrimLeft}The text was updated successfully, but these errors were encountered: