-
Notifications
You must be signed in to change notification settings - Fork 18.8k
Open
Labels
Milestone
Description
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 the cutset type problem:
- cmd/vet: report strings.Trim/TrimLeft/TrimRight with duplicate runes in cutset #46533
- proposal: cmd/vet warns when the cutset of strings.{Trim,TrimLeft,TrimRight} is not in order #47822
I read through this proposals and see the conclusion is no change will be made.
This cutset problem affects many developers:
- if we have known the problem already, we may not make the same mistake again.
- but if we doesn't know it in advance, we may likely make the mistake.
In python, str.{strip/rstrip/lstrip}('cutset') method works the same as in go strings.{Trim/TrimRight/TrimLeft}(s, "cutset"). Maybe this signature is ok.
If we:
- add new methods strings.{TrimCutset\TrimRightCutset\TrimLeftCutset}, and add
//Deprecatedandgo:linknameon strings.{Trim/TrimRight/TrimLeft}, we may make this clearer - or add new methods strings.{TrimCutset\TrimRightCutset\TrimLeftCutset}, and declare the
cutsetas []rune, and use this methods to reimplement strings.{Trim/TrimRight/TrimLeft}
GRbitcristaloleg, magical, seankhliao and thomasfearthboundkid
Metadata
Metadata
Assignees
Labels
Type
Projects
Status
Hold