Go

Go

Made by DeepSource

Found manual trimming of string SCC-S1017

Anti-pattern
Major
Autofix

Instead of using strings.HasPrefix and manual slicing, use the strings.TrimPrefix function. The original string will be returned if the string doesn't start with the prefix.

Using strings.TrimPrefix is idiomatic for trimming and avoids mistakes such as off-by-one.

Bad practice

if strings.HasPrefix(str, prefix) {
    str = str[len(prefix):]
}

Recommended

str = strings.TrimPrefix(str, prefix)