There is a format string like this:
"key1=value1&key2=value2"
How to convert this string to a map elegantly:
{"key1":"value1","key2":"value2"}
Is there any good utils like Guava's MapSplitter?
There is a format string like this:
"key1=value1&key2=value2"
How to convert this string to a map elegantly:
{"key1":"value1","key2":"value2"}
Is there any good utils like Guava's MapSplitter?
You can use strings.Split() function twice to split the entire string into a key=value pairs by & and then again to split each pair to key and value by =.
Quick playground without handling corner cases: https://go.dev/play/p/t8oMbA72GCB