One reason for not implementing it in the standard library is that there are many possible implementations. Do you want to reverse combining character sequences for example? Unicode is a complex beast and I suspect that reversing a string rune-by-rune may easily break important semantics. Is it even possible to do it correctly in general ?
On Sat, 15 Feb 2020, 17:13 Amarjeet Anand, <amarjeetanandsi...@gmail.com> wrote: > Thanks ian for the quick reply. > > As far as other languages are concerned, > Like Java, stringBuilder.reverse() seems a logical place to put this > feature. Because string builder gives us facility to generate a string, > overcoming the limitation of string immutability. What if I want to > generate a string in reverse order? > > Yeah, agree that its not difficult to implement. > > I need it quite often, maybe because of the kind of project am working on > currently, but can't advocate that every go programmer needs them > frequently. > > Anyways, thanks for the clarification. > > On Sat, 15 Feb, 2020, 10:14 PM Ian Lance Taylor, <i...@golang.org> wrote: > >> On Sat, Feb 15, 2020 at 8:37 AM Amarjeet Anand >> <amarjeetanandsi...@gmail.com> wrote: >> > >> > I was wondering why isn't there built-in string reverse function. Is it >> left intentionally because of some reason? >> > >> > Although strings are immutable in go, there are multiple ways to >> achieve this pretty easily. But having this function inbuilt will save our >> time because we need it quite often. >> >> It's been suggested, but it doesn't seem to come up that much, and >> it's easy to write your own version. Also, other languages don't seem >> to provide a corresponding function in their standard libraries. If >> you want to argue that it should be in the standard library, it would >> help to see several different cases where it comes up in real Go code. >> https://golang.org/doc/faq#x_in_std >> >> Ian >> > -- > You received this message because you are subscribed to the Google Groups > "golang-nuts" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to golang-nuts+unsubscr...@googlegroups.com. > To view this discussion on the web visit > https://groups.google.com/d/msgid/golang-nuts/CANFuhy-S%2Bdoq0kq3KF_BuCCQYa9Zqn0OUQXfovrMk%2BiC7_A0%3Dw%40mail.gmail.com > <https://groups.google.com/d/msgid/golang-nuts/CANFuhy-S%2Bdoq0kq3KF_BuCCQYa9Zqn0OUQXfovrMk%2BiC7_A0%3Dw%40mail.gmail.com?utm_medium=email&utm_source=footer> > . > -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/golang-nuts/CAJhgacjcxR30x45rQbYa6wxHpiDDMGC9M-kPF-iC4brX5Td4qQ%40mail.gmail.com.