// GetTypePkgPathAndName gets ths type and package path of the provided
// instance.
555597
func GetTypePkgPathAndName(i interface{}) string {
	t := reflect.TypeOf(i)
	if t.Kind() == reflect.Ptr || t.Kind() == reflect.Interface {
		t = t.Elem()
	}
	pkgPath := t.PkgPath()
	typeName := t.Name()
	if pkgPath == "" {
		return typeName
	}
	return fmt.Sprintf("%s.%s", pkgPath, typeName)
}
625788
func PackageAbsPath(p interface{}) (string, error) {
	switch t := p.(type) {
	case *types.Package:
		return PackageAbsPath(t.Path())
	case *ast.ImportSpec:
		return PackageAbsPath(t.Path.Value[1 : len(t.Path.Value)-1])
	case string:
		gopath := os.Getenv("GOPATH")
		for _, path := range filepath.SplitList(gopath) {
			fullPath := filepath.Join(path, "src", t)
			absPath, err := filepath.Abs(fullPath)
			if err != nil {
				continue
			}

			if _, err = os.Stat(fullPath); err != nil {
				continue
			}

			return absPath, nil
		}

		return "", fmt.Errorf("failed to find %q in GOPATH (%s)", t, gopath)
	}

	return "", fmt.Errorf("unsupported argument type for PackageFullPath: %T", p)
}
501635
func (f paramFiller) typeName(shape *Shape) string {
	if f.prefixPackageName && shape.Type == "structure" {
		return "*" + shape.API.PackageName() + "." + shape.GoTypeElem()
	}
	return shape.GoType()
}
61241
func GetPkgFullPath(short string) (string, error) {
	name, ok := PackageNameList[short]
	if !ok {
		return "", fmt.Errorf("no match package import path with given short name: %s", short)
	}
	return name, nil
}
514196
func (e TypeExpr) TypeName(pkgOverride string) string {
	pkgName := FirstNonEmpty(pkgOverride, e.PkgName)
	if pkgName == "" {
		return e.Expr
	}
	return e.Expr[:e.pkgIndex] + pkgName + "." + e.Expr[e.pkgIndex:]
}
848683
func get_type_path(e ast.Expr) (r type_path) {
	if e == nil {
		return type_path{"", ""}
	}

	switch t := e.(type) {
	case *ast.Ident:
		r.name = t.Name
	case *ast.StarExpr:
		r = get_type_path(t.X)
	case *ast.SelectorExpr:
		if ident, ok := t.X.(*ast.Ident); ok {
			r.pkg = ident.Name
		}
		r.name = t.Sel.Name
	}
	return
}
1009788
func (n *NotificationSubject) GetType() string {
	if n == nil || n.Type == nil {
		return ""
	}
	return *n.Type
}
911479
func (h *HandlerShared) getFindPackageFunc() FindPackageFunc {
	if h.FindPackage != nil {
		return h.FindPackage
	}
	return defaultFindPackageFunc
}
1215984
func pkgName(fset *token.FileSet, filename string) string {
	prog, _ := parser.ParseFile(fset, filename, nil, parser.PackageClauseOnly, nil, types.DefaultImportPathToName)
	if prog != nil {
		return prog.Name.Name
	}
	return ""
}
605413
func (ccpack *SignedCDSPackage) GetDepSpecBytes() []byte {
	//this has to be after creating a package and initializing it
	//If those steps fail, GetDepSpecBytes() should never be called
	if ccpack.sDepSpec == nil || ccpack.sDepSpec.ChaincodeDeploymentSpec == nil {
		panic("GetDepSpecBytes called on uninitialized package")
	}
	return ccpack.sDepSpec.ChaincodeDeploymentSpec
}
811524
func getPackageImportMap(astPackage *ast.Package) map[string]string {

	result := make(map[string]string)

	// Iterate files in this package
	// (There's also an *ast.Package.Imports property but it seems to be empty)
	for fileName, file := range astPackage.Files {
		// Iterate imports in this file
		for _, importSpec := range file.Imports {
			// Remove quotes
			packagePath := importSpec.Path.Value[1 : len(importSpec.Path.Value)-1]

			// Determine package name
			var packageName string
			if importSpec.Name != nil {
				// Package is aliased to another name
				packageName = importSpec.Name.Name

			} else {
				// Use the default name, the path's last element
				tmp := strings.Split(packagePath, "/")
				packageName = tmp[len(tmp)-1]
			}

			// Check for naming conflicts
			tmp, exists := result[packageName]
			if exists && tmp != packagePath {
				panic(fmt.Sprintf("Package naming conflict in %s: %s => %s, was already %s\n",
					fileName, packageName, tmp, packagePath))
			}

			result[packageName] = packagePath
		}

		// Add this file's local path to import list
		// - there may not be other references to this package
		tmp, exists := result[file.Name.Name]
		if exists && tmp != path.Dir(fileName) {
			fmt.Printf("WARNING: Possible package naming conflict in file %q: package %q "+
				"references both importdir %q and relative dir %q\n",
				fileName, file.Name.Name, tmp, path.Dir(fileName))
		}
		result[file.Name.Name] = path.Dir(fileName)
	}

	return result
}
1158891
func (c *PassphraseChange) findAndDecryptPrivatePGPKeys(m libkb.MetaContext) ([]libkb.GenericKey, error) {

	var keyList []libkb.GenericKey

	// Using a paper key makes TripleSec-synced keys unrecoverable
	if c.usingPaper {
		m.Debug("using a paper key, thus TripleSec-synced keys are unrecoverable")
		return keyList, nil
	}

	// Only use the synced secret keys:
	blocks, err := c.me.AllSyncedSecretKeys(m)
	if err != nil {
		return nil, err
	}

	secretRetriever := libkb.NewSecretStore(c.G(), c.me.GetNormalizedName())

	for _, block := range blocks {
		parg := m.SecretKeyPromptArg(libkb.SecretKeyArg{}, "passphrase change")
		key, err := block.PromptAndUnlock(m, parg, secretRetriever, c.me)
		if err != nil {
			return nil, err
		}
		keyList = append(keyList, key)
	}

	return keyList, nil
}
489955
func (b *Builder) FindPackages() []string {
	// Iterate packages in a predictable order.
	pkgPaths := []string{}
	for k := range b.typeCheckedPackages {
		pkgPaths = append(pkgPaths, string(k))
	}
	sort.Strings(pkgPaths)

	result := []string{}
	for _, pkgPath := range pkgPaths {
		if b.userRequested[importPathString(pkgPath)] {
			// Since walkType is recursive, all types that are in packages that
			// were directly mentioned will be included.  We don't need to
			// include all types in all transitive packages, though.
			result = append(result, pkgPath)
		}
	}
	return result
}
991314
func (ta *Table) GetPKColumn(index int) *TableColumn {
	return &ta.Columns[ta.PKColumns[index]]
}
801265
func GodelPropsDistPkgInfo(projectDir string) (godelgetter.PkgSrc, error) {
	wrapperSpec, err := specdir.New(projectDir, layout.WrapperSpec(), nil, specdir.Validate)
	if err != nil {
		return nil, errors.Wrapf(err, "unable to create wrapper spec")
	}
	configDir := wrapperSpec.Path(layout.WrapperConfigDir)

	propsFilePath := path.Join(configDir, fmt.Sprintf("%s.properties", layout.AppName))
	props, err := readPropertiesFile(propsFilePath)
	if err != nil {
		return nil, errors.Wrapf(err, "failed to read properties file %s", propsFilePath)
	}
	url, ok := props[propertiesURLKey]
	if !ok {
		return nil, errors.Wrapf(err, "properties file %s does not contain key %s", propsFilePath, propertiesURLKey)
	}
	checksum := props[propertiesChecksumKey]
	return godelgetter.NewPkgSrc(url, checksum), nil
}
840319
func GetKeyType(typename string) (keytype KeyType) {
	switch {
	case typename == "none":
		keytype = RT_NONE
	case typename == "string":
		keytype = RT_STRING
	case typename == "list":
		keytype = RT_LIST
	case typename == "set":
		keytype = RT_SET
	case typename == "zset":
		keytype = RT_ZSET
	default:
		panic("BUG - unknown type: " + string(keytype))
	}
	return
}
302228
func (p *PackageProvider) getCodePackageFromLegacyPP(name, version string) ([]byte, error) {
	codePackage, err := p.LegacyPP.GetChaincodeCodePackage(name, version)
	if err != nil {
		return nil, errors.Wrap(err, "error loading code package from ChaincodeDeploymentSpec")
	}
	return codePackage, nil
}