Ad
  • Custom User Avatar

    You're correct, and I would certainly use a Builder even on short strings.

    I wrote this solution when I was brand new to Go and had to pick it up quickly while moving teams at work. I don't think my solution is best practice despite the 12 votes :D

  • Custom User Avatar

    Based on my understanding of string concatenation, for long strings your function may have performance loss.
    The reason would be that additional memory allocations will be made with every string concatentation.

    You may find using a strings.Builder would help with performance (on long strings) due to less memory allocations being made.

  • Custom User Avatar

    Length property is not calculated.