O'Reilly logo
  • Rakesh Mandava thinks this is interesting:

This is a quadratic process that could be costly if the number of arguments is large, but for echo, that’s unlikely


Cover of The Go Programming Language


Generally speaking quadratic means something that pertains to squared numbers. In this context it means that the cost of the process is proportional to the square of the input size. This is because strings are concatenated using += operator which is expensive in Go as strings are immutable and a new string must be created in memory every time you concatenate. More efficient ways to concatenate strings include writing to bytes.Buffer and converting it to string, or using strings.Join function