quii / learn-go-with-tests

Learn Go with test-driven development
MIT License
21.71k stars 2.77k forks source link

Iteration chapter improvement #769

Open AptRoApt opened 1 month ago

AptRoApt commented 1 month ago

Strings concatenation is a great topic to learn through TDD, but this topic is not covered in this chapter.

Strings in Go are immutable, so memory reallocates on every change of a string. We can demonstrate this with an example by benchmarking and show a solution: strings.Builder from the strings package.

To do this we can:

I can make a pull request with this changes, if you want.

AptRoApt commented 1 month ago

I think that work with strings can be discussed after the chapter on arrays and slices. This section can cover not only strings.Builder, but also runes, bytes, and work with UTF-8.

quii commented 1 month ago

Great idea! Go for it