Black Lives Matter. Support the Equal Justice Initiative.

Source file src/internal/bytealg/indexbyte_generic.go

Documentation: internal/bytealg

     1  // Copyright 2018 The Go Authors. All rights reserved.
     2  // Use of this source code is governed by a BSD-style
     3  // license that can be found in the LICENSE file.
     4  
     5  //go:build !386 && !amd64 && !s390x && !arm && !arm64 && !ppc64 && !ppc64le && !mips && !mipsle && !mips64 && !mips64le && !riscv64 && !wasm
     6  // +build !386,!amd64,!s390x,!arm,!arm64,!ppc64,!ppc64le,!mips,!mipsle,!mips64,!mips64le,!riscv64,!wasm
     7  
     8  package bytealg
     9  
    10  func IndexByte(b []byte, c byte) int {
    11  	for i, x := range b {
    12  		if x == c {
    13  			return i
    14  		}
    15  	}
    16  	return -1
    17  }
    18  
    19  func IndexByteString(s string, c byte) int {
    20  	for i := 0; i < len(s); i++ {
    21  		if s[i] == c {
    22  			return i
    23  		}
    24  	}
    25  	return -1
    26  }
    27  

View as plain text