go-algorand icon indicating copy to clipboard operation
go-algorand copied to clipboard

go 1.18 upgrade: Replace occurrences of `strings.SplitN(arg, sep, 2)` with `strings.Cut(arg, sep)`

Open tzaffi opened this issue 3 years ago • 0 comments

Problem

Since go version 1.18, Cut() is available for splitting strings in the special case of n=2. The standard library's commentary for SplitN() seems to suggest that it is preferred:

image

Reference

https://pkg.go.dev/strings#Cut

Solution

Replace all occurrences in the codebase for splitting strings into exactly 2 pieces using strings.SplitN() to use strings.Cut(). Since the API's are not identical, an automatic change would require some thought, and it may end up easier to make the changes manually.

Dependencies

Urgency

Low

tzaffi avatar Sep 12 '22 15:09 tzaffi