I can read here: How to remove redundant spaces/whitespace from a string in Golang? that I can use regex or strings.Fields to remove duplicated spaces from strings.
I need to know a fast (performances matter here) way to remove ONLY duplicated (or more) spaces from a (maybe long) string and NOT remove new lines characters like \n.
Example:
"I have
[SPACE][SPACE][SPACE]duplicated spaces[SPACE][SPACE][SPACE]as you can see" => "I have[SPACE]duplicated spaces[SPACE]as you can see""I have
[SPACE][SPACE][SPACE]new lines\n\ntoo" => "I have[SPACE]new lines\n\ntoo"