Ответ 1
Пакет strings содержит HasPrefix и HasSuffix.
import "strings"
startsWith := strings.HasPrefix("prefix", "pre") // true
endsWith := strings.HasSuffix("suffix", "fix") // true
Просто любопытно узнать: почему нет стандартных функций, таких как startswith, endswith и т.д. как часть стандартных библиотек на языке программирования Go?
Пакет strings содержит HasPrefix и HasSuffix.
import "strings"
startsWith := strings.HasPrefix("prefix", "pre") // true
endsWith := strings.HasSuffix("suffix", "fix") // true