小编典典

Go 中没有开始和结束函数?

go

只是好奇地发现:为什么 Go 编程语言中没有标准函数(如开始、结束等)作为标准库的一部分?


阅读 136

收藏
2021-11-06

共1个答案

小编典典

字符串包中包含HasPrefixHasSuffix

import "strings"

startsWith := strings.HasPrefix("prefix", "pre") // true
endsWith := strings.HasSuffix("suffix", "fix") // true

play.golang.org

2021-11-06