bytealg_bootstrap.go 430 B

123456789101112131415161718
  1. // Copyright 2020 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. //go:build compiler_bootstrap
  5. // +build compiler_bootstrap
  6. package strconv
  7. // index returns the index of the first instance of c in s, or -1 if missing.
  8. func index(s string, c byte) int {
  9. for i := 0; i < len(s); i++ {
  10. if s[i] == c {
  11. return i
  12. }
  13. }
  14. return -1
  15. }