// GetPackage returns the package with the given GUID.
772151
func (client *Client) GetPackage(packageGUID string) (Package, Warnings, error) {
	request, err := client.newHTTPRequest(requestOptions{
		RequestName: internal.GetPackageRequest,
		URIParams:   internal.Params{"package_guid": packageGUID},
	})
	if err != nil {
		return Package{}, nil, err
	}

	var responsePackage Package
	response := cloudcontroller.Response{
		DecodeJSONResponseInto: &responsePackage,
	}
	err = client.connection.Make(request, &response)

	return responsePackage, response.Warnings, err
}
44506
func getImportDir(packageName string) string {
	packagePath, found := globalImportMap[packageName]
	if !found {
		return ""
	}

	// ./<packagePath> is needed to resolve references to plugin's own package
	searchList := []string{
		"./" + packageName,
		"./" + packagePath,
		"./vendor/" + packagePath,
		os.Getenv("GOPATH") + "/src/" + packagePath,
	}

	for _, testPath := range searchList {
		fp, err := os.Open(testPath)
		if err != nil {
			continue
		}
		stat, err := fp.Stat()
		if err != nil {
			continue
		}
		if !stat.IsDir() {
			continue
		}

		return testPath
	}

	return ""
}
1159464
func (ccpack *CDSPackage) GetChaincodeData() *ChaincodeData {
	//this has to be after creating a package and initializing it
	//If those steps fail, GetChaincodeData() should never be called
	if ccpack.depSpec == nil || ccpack.datab == nil || ccpack.id == nil {
		panic("GetChaincodeData called on uninitialized package")
	}
	return &ChaincodeData{Name: ccpack.depSpec.ChaincodeSpec.ChaincodeId.Name, Version: ccpack.depSpec.ChaincodeSpec.ChaincodeId.Version, Data: ccpack.datab, Id: ccpack.id}
}
956181
func GetPackageRelease(pkg string) (string, error) {
	if utils.Platform == utils.Darwin {
		return "", nil
	}

	command := getCommandToGetPackageRelease(pkg)
	thecmd := exec.Command(command[0], command[1:]...)
	output, err := thecmd.CombinedOutput()
	if err != nil {
		e := fmt.Errorf("unable to retrieve release of package '%s' with command:'%s' output: %s  error: %s\n", pkg, command, output, err)
		return "", e
	}

	release := strings.TrimSuffix(string(output), "\n")
	return release, nil
}
1368009
func (consumer *Consumer) Get() (*Package, error) {
	if consumer.HasUnacked() {
		return nil, fmt.Errorf("unacked Packages found")
	}
	return consumer.unsafeGet()
}
3692
func (p *PackageProvider) GetChaincodeCodePackage(name, version string) ([]byte, error) {
	codePackage, err := p.getCodePackageFromStore(name, version)
	if err == nil {
		return codePackage, nil
	}
	if _, ok := err.(*CodePackageNotFoundErr); !ok {
		// return the error if the hash cannot be retrieved or the code package
		// fails to load from the persistence store
		return nil, err
	}

	codePackage, err = p.getCodePackageFromLegacyPP(name, version)
	if err != nil {
		logger.Debug(err.Error())
		err = errors.Errorf("code package not found for chaincode with name '%s', version '%s'", name, version)
		return nil, err
	}
	return codePackage, nil
}
730733
func processPackage(fset *token.FileSet, pkgImportPath, pkgPath string, pkg *ast.Package) *model.SourceInfo {
	var (
		structSpecs     []*model.TypeInfo
		initImportPaths []string

		methodSpecs     = make(methodMap)
		validationKeys  = make(map[string]map[int]string)
		scanControllers = strings.HasSuffix(pkgImportPath, "/controllers") ||
			strings.Contains(pkgImportPath, "/controllers/")
		scanTests = strings.HasSuffix(pkgImportPath, "/tests") ||
			strings.Contains(pkgImportPath, "/tests/")
	)

	// For each source file in the package...
	utils.Logger.Info("Exaimining files in path", "package", pkgPath)
	for fname, file := range pkg.Files {
		// Imports maps the package key to the full import path.
		// e.g. import "sample/app/models" => "models": "sample/app/models"
		imports := map[string]string{}

		// For each declaration in the source file...
		for _, decl := range file.Decls {
			addImports(imports, decl, pkgPath)

			if scanControllers {
				// Match and add both structs and methods
				structSpecs = appendStruct(fname, structSpecs, pkgImportPath, pkg, decl, imports, fset)
				appendAction(fset, methodSpecs, decl, pkgImportPath, pkg.Name, imports)
			} else if scanTests {
				structSpecs = appendStruct(fname, structSpecs, pkgImportPath, pkg, decl, imports, fset)
			}

			// If this is a func... (ignore nil for external (non-Go) function)
			if funcDecl, ok := decl.(*ast.FuncDecl); ok && funcDecl.Body != nil {
				// Scan it for validation calls
				lineKeys := GetValidationKeys(fname, fset, funcDecl, imports)
				if len(lineKeys) > 0 {
					validationKeys[pkgImportPath+"."+getFuncName(funcDecl)] = lineKeys
				}

				// Check if it's an init function.
				if funcDecl.Name.Name == "init" {
					initImportPaths = []string{pkgImportPath}
				}
			}
		}
	}

	// Add the method specs to the struct specs.
	for _, spec := range structSpecs {
		spec.MethodSpecs = methodSpecs[spec.StructName]
	}

	return &model.SourceInfo{
		StructSpecs:     structSpecs,
		ValidationKeys:  validationKeys,
		InitImportPaths: initImportPaths,
	}
}
1340449
func (p *Packfile) Get(h plumbing.Hash) (plumbing.EncodedObject, error) {
	offset, err := p.FindOffset(h)
	if err != nil {
		return nil, err
	}

	return p.objectAtOffset(offset, h)
}
676645
func (client *Client) GetApplication(guid string) (Application, Warnings, error) {
	request, err := client.newHTTPRequest(requestOptions{
		RequestName: internal.GetAppRequest,
		URIParams:   Params{"app_guid": guid},
	})
	if err != nil {
		return Application{}, nil, err
	}

	var app Application
	response := cloudcontroller.Response{
		DecodeJSONResponseInto: &app,
	}

	err = client.connection.Make(request, &response)
	return app, response.Warnings, err
}
911479
func (h *HandlerShared) getFindPackageFunc() FindPackageFunc {
	if h.FindPackage != nil {
		return h.FindPackage
	}
	return defaultFindPackageFunc
}
438741
func (r Repository) GetBundle(id *charm.URL) (charm.Bundle, error) {
	bundleData := r.bundles[r.channel][*id]
	if bundleData == nil {
		return nil, errors.NotFoundf(id.String())
	}
	return bundleData, nil
}
491218
func goGetPackageDeps(repo, module string) []string {
	dir, deps := goGetDeps(repo, module)
	return goGetFiles(dir, deps)
}
717171
func PrimaryPackage(gocmd, path string, files []string) (*PkgInfo, error) {
	info, err := Package(path, files)
	if err != nil {
		return nil, err
	}

	if err := setImports(gocmd, info); err != nil {
		return nil, err
	}

	setDefault(info)
	setAliases(info)
	return info, nil
}
1359053
func (m *Migration) GetGUID() string {
	if m == nil || m.GUID == nil {
		return ""
	}
	return *m.GUID
}
1200378
func (g *Generator) defaultGoPackage() GoPackageName {
	p := g.PackageImportPath
	if i := strings.LastIndex(p, "/"); i >= 0 {
		p = p[i+1:]
	}
	return cleanPackageName(p)
}
1185096
func (impl *repoImpl) UnhidePackage(c context.Context, r *api.PackageRequest) (*empty.Empty, error) {
	return impl.setPackageHidden(c, r, model.Visible)
}
695556
func (c *Context) ResolvePackage(path string) (*Package, error) {
	if path == "." {
		return nil, errors.Errorf("%q is not a package", filepath.Join(c.Projectdir(), "src"))
	}
	path, err := relImportPath(filepath.Join(c.Projectdir(), "src"), path)
	if err != nil {
		return nil, err
	}
	if path == "." || path == ".." || strings.HasPrefix(path, "./") || strings.HasPrefix(path, "../") {
		return nil, errors.Errorf("import %q: relative import not supported", path)
	}
	return c.loadPackage(nil, path)
}