Ad
  • Custom User Avatar

    Even if there were ever a string long enough to justify splitting up the work, spinning up a goroutine for every single character would not be an efficient way of distributing the work. While goroutines are cheap, they’re not free.

    Another fun thing is that len(string) returns the number of bytes in the string, not the number of runes in it. This means if we have just one rune > utf8.RuneSelf this will deadlock, as it will attempt to receive st = <-ret for the number of bytes in string, while we will only spin off a do_work for every rune in the string.

    Once we fix that, we still end up with weird behavior, where there are \x00 values in your string because you’re indexing off the byte-length of s into the rune slice. https://play.golang.org/p/9WcBHj0hiQK