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

proposal: strings: function: new function to reverse a string #46568

Closed
0x4f53 opened this issue Jun 4, 2021 · 1 comment
Closed

proposal: strings: function: new function to reverse a string #46568

0x4f53 opened this issue Jun 4, 2021 · 1 comment

Comments

@0x4f53
Copy link

0x4f53 commented Jun 4, 2021

Golang doesn't seem to have an inbuilt function to reverse a given string. Here is my proposal for a basic function to reverse a string in Golang.

func Reverse(s string) string {
    var reversed string
    for _, v := range s {
        reversed = string(v) + result
    }
    return reversed
}

This function can be added to src/strings/strings.go, along with other string functions such as explode, trim, uppercase etc.

@gopherbot gopherbot added this to the Proposal milestone Jun 4, 2021
@ALTree
Copy link
Member

ALTree commented Jun 4, 2021

Hi,

this has been proposed, and rejected, in the past. See #14777 and #36887, in particular #36887 (comment):

strings.Reverse is a duplicate of #14777. It remains not needed often enough to merit inclusion in the standard library.

Closing here as a dup.

@ALTree ALTree closed this as completed Jun 4, 2021
@golang golang locked and limited conversation to collaborators Jun 4, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

3 participants