最近看到 go 的源码库,比如 bytes 库
Count()函数如下:
func Count(s, sep []byte) int {
if len(sep) == 1 && cpu.X86.HasPOPCNT {
return countByte(s, sep[0])
}
return countGeneric(s, sep)
}
然后看了下 countByte 库写法是下面这样:
func countByte(s []byte, c byte) int
库函数为什么可以这么写呢?没有实体?不应该语法报错吗?怎么执行呢? 来位好心人解释下吧!