IndexByte
IndexByte 返回 c 在 s 中第一次出现的位置,不存在则返回-1。
IndexByte
函数定义
func IndexByte(s string, c byte) int
代码示例
package main
import (
"fmt"
"strings"
)
func main() {
fmt.Println(strings.IndexByte("golang", 'g')) //0
fmt.Println(strings.IndexByte("gophers", 'h')) //3
fmt.Println(strings.IndexByte("golang", 'x')) //-1
}