return nil, errors.New("x509: no DEK-Info header in block")
}
- idx := strings.IndexByte(dek, ',')
+ idx := strings.Index(dek, ",")
if idx == -1 {
return nil, errors.New("x509: malformed DEK-Info header")
}
// PackageName returns the package part of the symbol name,
// or the empty string if there is none.
func (s *Sym) PackageName() string {
- if i := strings.IndexByte(s.Name, '.'); i != -1 {
+ if i := strings.Index(s.Name, "."); i != -1 {
return s.Name[0:i]
}
return ""
// ReceiverName returns the receiver type name of this symbol,
// or the empty string if there is none.
func (s *Sym) ReceiverName() string {
- l := strings.IndexByte(s.Name, '.')
+ l := strings.Index(s.Name, ".")
r := strings.LastIndex(s.Name, ".")
if l == -1 || r == -1 || l == r {
return ""
// parseTag splits a struct field's json tag into its name and
// comma-separated options.
func parseTag(tag string) (string, tagOptions) {
- if idx := strings.IndexByte(tag, ','); idx != -1 {
+ if idx := strings.Index(tag, ","); idx != -1 {
return tag[:idx], tagOptions(tag[idx+1:])
}
return tag, tagOptions("")
s := string(o)
for s != "" {
var next string
- i := strings.IndexByte(s, ',')
+ i := strings.Index(s, ",")
if i >= 0 {
s, next = s[:i], s[i+1:]
}
// Split the tag from the xml namespace if necessary.
tag := f.Tag.Get("xml")
- if i := strings.IndexByte(tag, ' '); i >= 0 {
+ if i := strings.Index(tag, " "); i >= 0 {
finfo.xmlns, tag = tag[:i], tag[i+1:]
}
if !ok {
return
}
- i := strings.IndexByte(s, ':')
+ i := strings.Index(s, ":")
if i < 0 {
name.Local = s
} else {
// Split at colon.
line = strings.TrimSpace(line[4:])
- i := strings.IndexByte(line, ':')
+ i := strings.Index(line, ":")
if i < 0 {
return fmt.Errorf("%s: invalid #cgo line: %s", filename, orig)
}
if name == "" {
return false
}
- if i := strings.IndexByte(name, ','); i >= 0 {
+ if i := strings.Index(name, ","); i >= 0 {
// comma-separated list
return ctxt.match(name[:i]) && ctxt.match(name[i+1:])
}
// name_$(GOOS)_$(GOARCH)_test.*
//
func (ctxt *Context) goodOSArchFile(name string) bool {
- if dot := strings.IndexByte(name, '.'); dot != -1 {
+ if dot := strings.Index(name, "."); dot != -1 {
name = name[:dot]
}
l := strings.Split(name, "_")
* Check for vertical "line of stars" and correct prefix accordingly.
*/
lineOfStars := false
- if i := strings.IndexByte(prefix, '*'); i >= 0 {
+ if i := strings.Index(prefix, "*"); i >= 0 {
// Line of stars present.
if i > 0 && prefix[i-1] == ' ' {
i-- // remove trailing blank from prefix so stars remain aligned
}
// check for a quotient
- sep := strings.IndexByte(s, '/')
+ sep := strings.Index(s, "/")
if sep >= 0 {
if _, ok := z.a.SetString(s[0:sep], 10); !ok {
return nil, false
}
// check for a decimal point
- sep = strings.IndexByte(s, '.')
+ sep = strings.Index(s, ".")
// check for an exponent
e := strings.IndexAny(s, "eE")
var exp Int
// When any of the arguments result in a standard violation then
// FormatMediaType returns the empty string.
func FormatMediaType(t string, param map[string]string) string {
- slash := strings.IndexByte(t, '/')
+ slash := strings.Index(t, "/")
if slash == -1 {
return ""
}
// The returned map, params, maps from the lowercase
// attribute to the attribute value with its case preserved.
func ParseMediaType(v string) (mediatype string, params map[string]string, err error) {
- i := strings.IndexByte(v, ';')
+ i := strings.Index(v, ";")
if i == -1 {
i = len(v)
}
}
pmap := params
- if idx := strings.IndexByte(key, '*'); idx != -1 {
+ if idx := strings.Index(key, "*"); idx != -1 {
baseName := key[:idx]
if continuation == nil {
continuation = make(map[string]map[string]string)
func envMap(env []string) map[string]string {
m := make(map[string]string)
for _, kv := range env {
- if idx := strings.IndexByte(kv, '='); idx != -1 {
+ if idx := strings.Index(kv, "="); idx != -1 {
m[kv[:idx]] = kv[idx+1:]
}
}
continue
}
parts[0] = strings.TrimSpace(parts[0])
- j := strings.IndexByte(parts[0], '=')
+ j := strings.Index(parts[0], "=")
if j < 0 {
continue
}
}
attr, val := parts[i], ""
- if j := strings.IndexByte(attr, '='); j >= 0 {
+ if j := strings.Index(attr, "="); j >= 0 {
attr, val = attr[:j], attr[j+1:]
}
lowerAttr := strings.ToLower(attr)
continue
}
name, val := parts[i], ""
- if j := strings.IndexByte(name, '='); j >= 0 {
+ if j := strings.Index(name, "="); j >= 0 {
name, val = name[:j], name[j+1:]
}
if !isCookieNameValid(name) {
if ra == "" {
continue
}
- i := strings.IndexByte(ra, '-')
+ i := strings.Index(ra, "-")
if i < 0 {
return nil, errors.New("invalid range")
}
if !strings.HasPrefix(vers, "HTTP/") {
return 0, 0, false
}
- dot := strings.IndexByte(vers, '.')
+ dot := strings.Index(vers, ".")
if dot < 0 {
return 0, 0, false
}
// parseRequestLine parses "GET /foo HTTP/1.1" into its three parts.
func parseRequestLine(line string) (method, requestURI, proto string, ok bool) {
- s1 := strings.IndexByte(line, ' ')
- s2 := strings.IndexByte(line[s1+1:], ' ')
+ s1 := strings.Index(line, " ")
+ s2 := strings.Index(line[s1+1:], " ")
if s1 < 0 || s2 < 0 {
return
}
}
var query string
- if i := strings.IndexByte(urlStr, '?'); i != -1 {
+ if i := strings.Index(urlStr, "?"); i != -1 {
urlStr, query = urlStr[:i], urlStr[i:]
}
if pattern[0] != '/' {
// In pattern, at least the last character is a '/', so
// strings.Index can't be -1.
- path = pattern[strings.IndexByte(pattern, '/'):]
+ path = pattern[strings.Index(pattern, "/"):]
}
mux.m[pattern[0:n-1]] = muxEntry{h: RedirectHandler(path, StatusMovedPermanently), pattern: pattern}
}
return
}
userinfo, host := authority[:i], authority[i+1:]
- if strings.IndexByte(userinfo, ':') < 0 {
+ if strings.Index(userinfo, ":") < 0 {
if userinfo, err = unescape(userinfo, encodeUserPassword); err != nil {
return
}
continue
}
value := ""
- if i := strings.IndexByte(key, '='); i >= 0 {
+ if i := strings.Index(key, "="); i >= 0 {
key, value = key[:i], key[i+1:]
}
key, err1 := QueryUnescape(key)
}
want := run(t, []string{"/bin/hostname"})
if hostname != want {
- i := strings.IndexByte(hostname, '.')
+ i := strings.Index(hostname, ".")
if i < 0 || hostname[0:i] != want {
t.Errorf("Hostname() = %q, want %q", hostname, want)
}
// say: "It is expected to be a comma separated list of
// personal data where the first item is the full name of the
// user."
- if i := strings.IndexByte(u.Name, ','); i >= 0 {
+ if i := strings.Index(u.Name, ","); i >= 0 {
u.Name = u.Name[:i]
}
return u, nil
star, chunk, pattern = scanChunk(pattern)
if star && chunk == "" {
// Trailing * matches rest of string unless it has a /.
- return strings.IndexByte(name, '/') < 0, nil
+ return strings.Index(name, "/") < 0, nil
}
// Look for match at current position.
t, ok, err := matchChunk(chunk, name)
out[n] = -1
out[n+1] = -1
} else {
- k := strings.IndexByte(pair, '-')
+ k := strings.Index(pair, "-")
if k < 0 {
t.Fatalf("%s:%d: invalid pair %s", file, lineno, pair)
}
continue Reading
}
case ':':
- i := strings.IndexByte(flag[1:], ':')
+ i := strings.Index(flag[1:], ":")
if i < 0 {
t.Logf("skip: %s", line)
continue Reading
// in Expand, so for instance $1 represents the text of the first submatch.
func (re *Regexp) ReplaceAllString(src, repl string) string {
n := 2
- if strings.IndexByte(repl, '$') >= 0 {
+ if strings.Index(repl, "$") >= 0 {
n = 2 * (re.numSubexp + 1)
}
b := re.replaceAll(nil, src, n, func(dst []byte, match []int) []byte {
func (re *Regexp) expand(dst []byte, template string, bsrc []byte, src string, match []int) []byte {
for len(template) > 0 {
- i := strings.IndexByte(template, '$')
+ i := strings.Index(template, "$")
if i < 0 {
break
}
}
func parseScript(line string, scripts map[string][]Script) {
- comment := strings.IndexByte(line, '#')
+ comment := strings.Index(line, "#")
if comment >= 0 {
line = line[0:comment]
}