Skip to content

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

@0x4f53

Description

@0x4f53

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.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions