Proposal Details
as there many usage of Replace(old, new, 1). I Proposal to add ReplaceOnce to strings and bytes package. Like wise ReplaceAll.
func ReplaceOnce(s, old, new string) string {
return Replace(s, old, new, 1)
}
func ReplaceOnce(s, old, new []byte) []byte {
return Replace(s, old, new, 1)
}
Comment From: seankhliao
Many does not quite rise to the level of majority ~65% https://github.com/golang/go/issues/27864#issuecomment-424852672 when ReplaceAll was added. plus once we add a function, some other value will take over the top as spot.
Once is also longer than , 1
, and arguably generates confusion about why it exists. All at least reduces confusion about negative numbers.
Comment From: zigo101
This got closed?
@seankhliao So you really think your opinion is always correct and you have the right to close any proposals? Please respect community members.
@aclements @ianlancetaylor