My most common use case for reversing strings has not come up in Go yet - basically, some languages provide a string search function that finds a character or substring starting from the beginning of the string. For example, in T-SQL, CharIndex. If they do not provide a corresponding search that works from the end towards the beginning, then removing something at the end of the string involves either searching to exhaustion then backing up to the last found index - this is easy in an imperative language like Go but trickier in a set-based language like SQL - or cheating by reversing the string, performing the search and modification, and reversing it again.
UPDATE Addresses SET Zip = SUBSTRING(Addr,LEN(Addr)-CHARINDEX(' ',REVERSE(Addr))+2,99) Another use-case involves zero-filling a number to right align it (again in SQL) and ensure a proper field-size: REVERSE(SUBSTRING(REVERSE('000000000000' + UPC),1,12)) These are janky solutions that only work because I know the data being operated on is ASCII and just save doing some fiddly math instead. I guess this is neatly reflected by the fact that I only managed to find examples when I was searching the folder where I did my data conversions for customers - a search in the actual code found no instances. I have not needed it in Go code so far. -- 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/81d73b9b-a234-460a-a415-fb828b692dc9%40googlegroups.com.