// matchGoImport returns the metaImport from imports matching importPath.
// An error is returned if there are multiple matches.
// errNoMatch is returned if none match.
502899
func matchGoImport(imports []metaImport, importPath string) (_ metaImport, err error) {
	match := -1
	for i, im := range imports {
		if !strings.HasPrefix(importPath, im.Prefix) {
			continue
		}
		if match != -1 {
			err = fmt.Errorf("multiple meta tags match import path %q", importPath)
			return
		}
		match = i
	}
	if match == -1 {
		err = errNoMatch
		return
	}
	return imports[match], nil
}
1006568
func (f Filter) MatchObjectContent(objects []types.ObjectContent) []types.ManagedObjectReference {
	var refs []types.ManagedObjectReference

	for _, o := range objects {
		if f.MatchPropertyList(o.PropSet) {
			refs = append(refs, o.Obj)
		}
	}

	return refs
}
904702
func (v *Module) GetImportPath() (o string) {
	if v != nil {
		o = v.ImportPath
	}
	return
}
1138492
func GoImports(data []byte) (fmted []byte, err error) {
	options := imports.Options{
		TabWidth:  8,
		TabIndent: true,
		Comments:  true,
		Fragment:  true,
	}
	if fmted, err = imports.Process("", data, &options); err != nil {
		var extraInfos string
		switch errval := err.(type) {
		case scanner.ErrorList:
			lines := strings.Split(string(data), "\n")
			if len(errval) > 0 {
				errelem := errval[0]
				minline := errelem.Pos.Line - 4
				if minline < 0 {
					minline = 0
				}
				maxline := errelem.Pos.Line + 5
				if maxline >= len(lines) {
					maxline = len(lines)
				}
				extraInfos = strings.Join(lines[minline:maxline], "\n")
			}
		}
		if len(extraInfos) > 0 {
			return fmted, ErrGoImportsFailed1.New(err, extraInfos)
		}
		return fmted, ErrGoImportsFailed.New(err)
	}
	return
}
795678
func NewImport(name, path string) *ImportSpec {
	return &ImportSpec{Name: name, Path: path}
}
315971
func NewRegexpFakeTransport(allMatchers []*Matcher) (http.RoundTripper, error) {
	var result regexpFakeTransport = []*regexPair{}
	for _, matcher := range allMatchers {
		r, err := regexp.Compile(matcher.URLRegex)
		if err != nil {
			return nil, err
		}
		pair := regexPair{r, matcher.Fn}
		result = append(result, &pair)
	}
	return result, nil
}
992925
func AttributeImports(att *design.AttributeDefinition, imports []*ImportSpec, seen []*design.AttributeDefinition) []*ImportSpec {

	for _, a := range seen {
		if att == a {
			return imports
		}
	}
	seen = append(seen, att)

	if tname, ok := att.Metadata["struct:field:type"]; ok {
		if len(tname) > 1 {
			tagImp := SimpleImport(tname[1])
			impSlice := []*ImportSpec{tagImp}
			imports = appendImports(imports, impSlice)
		}
	}

	switch t := att.Type.(type) {
	case *design.UserTypeDefinition:
		return appendImports(imports, AttributeImports(t.AttributeDefinition, imports, seen))
	case *design.MediaTypeDefinition:
		return appendImports(imports, AttributeImports(t.AttributeDefinition, imports, seen))
	case design.Object:
		t.IterateAttributes(func(n string, t *design.AttributeDefinition) error {
			imports = appendImports(imports, AttributeImports(t, imports, seen))
			return nil
		})
		return imports
	case *design.Array:
		return appendImports(imports, AttributeImports(t.ElemType, imports, seen))
	case *design.Hash:
		imports = appendImports(imports, AttributeImports(t.KeyType, imports, seen))
		return appendImports(imports, AttributeImports(t.ElemType, imports, seen))
	}

	return imports
}
331853
func IsValidRemotePath(importPath string) bool {

	parts := strings.Split(importPath, "/")

	if !validTLDs[path.Ext(parts[0])] {
		return false
	}

	if !validHost.MatchString(parts[0]) {
		return false
	}

	for _, part := range parts[1:] {
		if !isValidPathElement(part) {
			return false
		}
	}

	return true
}
170886
func Match(pattern, name string) (bool, error) {
	return defaultGlobber.Match(pattern, name)
}
27500
func (cs ClientService) NeedImportJSON() bool {
	for _, cm := range cs.Methods {
		if cm.needImportEncodingJSON() {
			return true
		}
	}
	return false
}
1149731
func (g *Generator) generateImports() {
	// We almost always need a proto import.  Rather than computing when we
	// do, which is tricky when there's a plugin, just import it and
	// reference it later. The same argument applies to the fmt and math packages.
	if gogoproto.ImportsGoGoProto(g.file.FileDescriptorProto) {
		g.PrintImport(g.Pkg["proto"], g.ImportPrefix+"github.com/gogo/protobuf/proto")
		if gogoproto.RegistersGolangProto(g.file.FileDescriptorProto) {
			g.PrintImport(g.Pkg["golang_proto"], g.ImportPrefix+"github.com/golang/protobuf/proto")
		}
	} else {
		g.PrintImport(g.Pkg["proto"], g.ImportPrefix+"github.com/golang/protobuf/proto")
	}
	g.PrintImport(g.Pkg["fmt"], "fmt")
	g.PrintImport(g.Pkg["math"], "math")

	for i, s := range g.file.Dependency {
		fd := g.fileByName(s)
		// Do not import our own package.
		if fd.PackageName() == g.packageName {
			continue
		}
		filename := fd.goFileName()
		// By default, import path is the dirname of the Go filename.
		importPath := path.Dir(filename)
		if substitution, ok := g.ImportMap[s]; ok {
			importPath = substitution
		}
		importPath = g.ImportPrefix + importPath
		// Skip weak imports.
		if g.weak(int32(i)) {
			g.P("// skipping weak import ", fd.PackageName(), " ", strconv.Quote(importPath))
			continue
		}
		// We need to import all the dependencies, even if we don't reference them,
		// because other code and tools depend on having the full transitive closure
		// of protocol buffer types in the binary.
		if _, ok := g.usedPackages[fd.PackageName()]; ok {
			g.PrintImport(fd.PackageName(), importPath)
		} else {
			g.P("import _ ", strconv.Quote(importPath))
		}
	}
	g.P()
	for _, s := range g.customImports {
		s1 := strings.Map(badToUnderscore, s)
		g.PrintImport(s1, s)
	}
	g.P()
	g.P("// Reference imports to suppress errors if they are not otherwise used.")
	g.P("var _ = ", g.Pkg["proto"], ".Marshal")
	if gogoproto.ImportsGoGoProto(g.file.FileDescriptorProto) && gogoproto.RegistersGolangProto(g.file.FileDescriptorProto) {
		g.P("var _ = ", g.Pkg["golang_proto"], ".Marshal")
	}
	g.P("var _ = ", g.Pkg["fmt"], ".Errorf")
	g.P("var _ = ", g.Pkg["math"], ".Inf")
	for _, cimport := range g.customImports {
		if cimport == "time" {
			g.P("var _ = time.Kitchen")
			break
		}
	}
	g.P()
}
485192
func ParsedImports(imp []*ast.Import) func(r *Rego) {
	return func(r *Rego) {
		r.parsedImports = append(r.parsedImports, imp...)
	}
}
509980
func (ctx *Context) findImportPath(dir string) (importPath, gopath string, err error) {
	dirResolved, err := filepath.EvalSymlinks(dir)
	if err != nil {
		return "", "", err
	}
	dirs := make([]string, 1)
	dirs = append(dirs, dir)
	if dir != dirResolved {
		dirs = append(dirs, dirResolved)
	}

	for _, gopath := range ctx.GopathList {
		for _, dir := range dirs {
			if pathos.FileHasPrefix(dir, gopath) || pathos.FileStringEquals(dir, gopath) {
				importPath = pathos.FileTrimPrefix(dir, gopath)
				importPath = pathos.SlashToImportPath(importPath)
				return importPath, gopath, nil
			}
		}
	}
	return "", "", ErrNotInGOPATH{dir}
}
1216439
func (indom *PCPInstanceDomain) MatchInstances(ins []string) bool {
	if len(ins) != len(indom.instances) {
		return false
	}

	for _, i := range ins {
		if _, ok := indom.instances[i]; !ok {
			return false
		}
	}

	return true
}
1268494
func (s *ServerV2) MatchAgainst(labels map[string]string) bool {
	if labels != nil {
		myLabels := s.GetAllLabels()
		for key, value := range labels {
			if myLabels[key] != value {
				return false
			}
		}
	}
	return true
}
182327
func (d *FileDescriptor) goPackageOption() (impPath GoImportPath, pkg GoPackageName, ok bool) {
	opt := d.GetOptions().GetGoPackage()
	if opt == "" {
		return "", "", false
	}
	// A semicolon-delimited suffix delimits the import path and package name.
	sc := strings.Index(opt, ";")
	if sc >= 0 {
		return GoImportPath(opt[:sc]), cleanPackageName(opt[sc+1:]), true
	}
	// The presence of a slash implies there's an import path.
	slash := strings.LastIndex(opt, "/")
	if slash >= 0 {
		return GoImportPath(opt), cleanPackageName(opt[slash+1:]), true
	}
	return "", cleanPackageName(opt), true
}
143202
func regexMatch(pattern, path string) bool {
	matched, e := regexp.MatchString(pattern, path)
	errorIf(probe.NewError(e).Trace(pattern), "Unable to regex match with input pattern.")
	return matched
}