Go

Go

Made by DeepSource

strings.Index call cause unwanted allocations CRT-P0004

Performance
Major
Autofix

[]byte to string conversion is required when passing the arguments to strings.Index, leading to unwanted allocations. It is preferred to use calls that prevent (or minimize) such allocations (e.g., bytes.Index, etc.).

Bad practice

strings.Index(string(x), y)

Recommended

bytes.Index(x, []byte(y))

References