// TypeByPackageName return the type by its package and name
487476
func TypeByPackageName(pkgPath string, name string) Type {
	initOnce.Do(discoverTypes)
	pkgTypes := packages[pkgPath]
	if pkgTypes == nil {
		return nil
	}
	return Type2(pkgTypes[name])
}
1104750
func (g *Generator) GoPackageName(importPath GoImportPath) GoPackageName {
	if name, ok := g.packageNames[importPath]; ok {
		return name
	}
	name := cleanPackageName(baseName(string(importPath)))
	for i, orig := 1, name; g.usedPackageNames[name] || isGoPredeclaredIdentifier[string(name)]; i++ {
		name = orig + GoPackageName(strconv.Itoa(i))
	}
	g.packageNames[importPath] = name
	g.usedPackageNames[name] = true
	return name
}
629408
func (p *Package) Type(typeName string) *Type {
	if t, ok := p.Types[typeName]; ok {
		return t
	}
	if p.Path == "" {
		// Import the standard builtin types!
		if t, ok := builtins.Types[typeName]; ok {
			p.Types[typeName] = t
			return t
		}
	}
	t := &Type{Name: Name{Package: p.Path, Name: typeName}}
	p.Types[typeName] = t
	return t
}
68487
func (err *Error) TypeName() string {
	if _, ok := err.Err.(uncaughtPanic); ok {
		return "panic"
	}
	if name := reflect.TypeOf(err.Err).String(); len(name) > 0 {
		return name
	}
	return "error"
}
980232
func TypeGroupByName(name string) *WorkItemTypeGroup {
	for _, t := range TypeGroups() {
		if t.Name == name {
			return &t
		}
	}
	return nil
}
317627
func TypeByFilename(fullFilename string) string {
	ext := filepath.Ext(fullFilename)
	return TypeByExtension(ext)
}
437825
func (g *Generator) SetPackageName(name string) {
	g.packageName = name
	g.SetVar("packageName", name)
}
689955
func (w *Wrapper) allPackagesInOrder() []*PackageInfo {
	result := make([]*PackageInfo, 0, len(w.allPackages))
	names := make([]string, 0, len(w.allPackages))
	for name := range w.allPackages {
		names = append(names, name)
	}
	sort.Strings(names)
	for _, name := range names {
		result = append(result, w.allPackages[name])
	}
	return result
}
971822
func (l *LanguageOpts) ManglePackageName(name, suffix string) string {
	if name == "" {
		return suffix
	}
	pth := filepath.ToSlash(filepath.Clean(name)) // preserve path
	_, pkg := path.Split(pth)                     // drop path
	return l.MangleName(swag.ToFileName(pkg), suffix)
}
1053565
func (g *Generator) SetPackageNames() {
	// Register the name for this package.  It will be the first name
	// registered so is guaranteed to be unmodified.
	pkg, explicit := g.genFiles[0].goPackageName()

	// Check all files for an explicit go_package option.
	for _, f := range g.genFiles {
		thisPkg, thisExplicit := f.goPackageName()
		if thisExplicit {
			if !explicit {
				// Let this file's go_package option serve for all input files.
				pkg, explicit = thisPkg, true
			} else if thisPkg != pkg {
				g.Fail("inconsistent package names:", thisPkg, pkg)
			}
		}
	}

	// If we don't have an explicit go_package option but we have an
	// import path, use that.
	if !explicit {
		p := g.defaultGoPackage()
		if p != "" {
			pkg, explicit = p, true
		}
	}

	// If there was no go_package and no import path to use,
	// double-check that all the inputs have the same implicit
	// Go package name.
	if !explicit {
		for _, f := range g.genFiles {
			thisPkg, _ := f.goPackageName()
			if thisPkg != pkg {
				g.Fail("inconsistent package names:", thisPkg, pkg)
			}
		}
	}

	g.packageName = RegisterUniquePackageName(pkg, g.genFiles[0])

	// Register the support package names. They might collide with the
	// name of a package we import.
	g.Pkg = map[string]string{
		"fmt":          RegisterUniquePackageName("fmt", nil),
		"math":         RegisterUniquePackageName("math", nil),
		"proto":        RegisterUniquePackageName("proto", nil),
		"golang_proto": RegisterUniquePackageName("golang_proto", nil),
	}

AllFiles:
	for _, f := range g.allFiles {
		for _, genf := range g.genFiles {
			if f == genf {
				// In this package already.
				uniquePackageName[f.FileDescriptorProto] = g.packageName
				continue AllFiles
			}
		}
		// The file is a dependency, so we want to ignore its go_package option
		// because that is only relevant for its specific generated output.
		pkg := f.GetPackage()
		if pkg == "" {
			pkg = baseName(*f.Name)
		}
		RegisterUniquePackageName(pkg, f)
	}
}
768116
func (d debExecutable) Package() string {
	if d.PackageName != "" {
		return d.PackageName
	}
	return d.BinaryName
}
215484
func (i *InitContext) GetByType(t Type) (map[string]*Plugin, error) {
	p, ok := i.plugins.byTypeAndID[t]
	if !ok {
		return nil, errors.Wrapf(errdefs.ErrNotFound, "no plugins registered for %s", t)
	}

	return p, nil
}
485301
func GetTypeName(schema proto.Schema) string {
	t := &typeName{}
	schema.Accept(t)
	return t.Name
}
808432
func (s *CreateModelPackageInput) SetModelPackageName(v string) *CreateModelPackageInput {
	s.ModelPackageName = &v
	return s
}
1306332
func addPackage(pkgName, typeStr string) string {
	if typeStr == "" {
		return ""
	}

	// we can't use raml package to get basic type and decide whether it is array
	// or not because in this phase the type is already Go type, not RAML type
	switch {
	case strings.HasPrefix(typeStr, "[][]"): // bidimensi array
		return "[][]" + addPackage(pkgName, strings.TrimPrefix(typeStr, "[][]"))
	case strings.HasPrefix(typeStr, "[]"): // array array
		return "[]" + addPackage(pkgName, strings.TrimPrefix(typeStr, "[]"))
	default:
		return aliasPackage(fmt.Sprintf("%v.%v", pkgName, typeStr))
	}
}
9745
func isPackage(pkg *types.Package, path string) bool {
	if pkg == nil {
		return false
	}

	return pkg.Path() == path ||
		strings.HasSuffix(pkg.Path(), "/vendor/"+path)
}
212768
func typeName(mt *design.MediaTypeDefinition) string {
	if mt.IsError() {
		return "ErrorResponse"
	}
	return codegen.GoTypeName(mt, mt.AllRequired(), 1, false)
}