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

Let collections.Reverse work on strings #12839

Open
McShelby opened this issue Sep 7, 2024 · 4 comments
Open

Let collections.Reverse work on strings #12839

McShelby opened this issue Sep 7, 2024 · 4 comments
Labels
Milestone

Comments

@McShelby
Copy link

McShelby commented Sep 7, 2024

It is currently hard to reverse a string. This forum thread discuses some workarounds but the best would be to let collections.Reverse do the job.

As @jmooring mentioned in the thread, this could probably lead to invalid unicode strings in case of non-ascii characters (this depends on how strings are represented in go and which set of functions will be used to reverse the string - I am not experienced in go).

So as a limitation it may only result in a reversed binary buffer instead of a usable reversed string.

@jmooring
Copy link
Member

jmooring commented Sep 7, 2024

If I were looking in our documentation for a template function that reverses a string, I would look for something in the strings namespace.

The string "Hello 👋🏿" will be difficult to properly reverse.

@bep
Copy link
Member

bep commented Sep 7, 2024

The string "Hello 👋🏿" will be difficult to properly reverse.

Well, it's not ... impossible. My question is how useful it is. I have not read the discussion linked above; what is the use case and is it a common use case?

@bep bep removed the NeedsTriage label Sep 7, 2024
@bep bep added this to the v0.134.1 milestone Sep 7, 2024
@jmooring
Copy link
Member

jmooring commented Sep 7, 2024

how useful it is

This is the first request I've seen.

@McShelby
Copy link
Author

McShelby commented Sep 7, 2024

It was a solution (or better: workaround) for a different problem. I would say it's quite unusual and of limited use to the public.

But speaking in general, it was quite surprising to me, that there isn't such a function.

@bep bep modified the milestones: v0.134.1, Unscheduled Sep 9, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants