在源代码中:
// Contains returns true if substr is within s.
func Contains(s, substr string) bool {
return Index(s, substr) >= 0
}
// ContainsAny returns true if any Unicode code points in chars are within s.
func ContainsAny(s, chars string) bool {
return IndexAny(s, chars) >= 0
}
唯一的区别似乎是 substr
和 chars 中的 Unicode 代码点
。我编写了一些测试来测试它们两者。它们的行为似乎是相同的。我不理解何时使用哪个。