// LoadPkgNameList loads package name pairs.
16327
func LoadPkgNameList() error {
	if !base.IsFile(PkgNameListFile) {
		return nil
	}

	data, err := ioutil.ReadFile(PkgNameListFile)
	if err != nil {
		return fmt.Errorf("fail to load package name list: %v", err)
	}

	pkgs := strings.Split(string(data), "\n")
	for i, line := range pkgs {
		infos := strings.Split(line, "=")
		if len(infos) != 2 {
			// Last item might be empty line.
			if i == len(pkgs)-1 {
				continue
			}
			return fmt.Errorf("fail to parse package name: %v", line)
		}
		PackageNameList[strings.TrimSpace(infos[0])] = strings.TrimSpace(infos[1])
	}
	return nil
}
1142046
func (k KeybaseServiceMeasured) LoadUserPlusKeys(
	ctx context.Context, uid keybase1.UID, pollForKID keybase1.KID,
	offline keybase1.OfflineAvailability) (userInfo idutil.UserInfo, err error) {
	k.loadUserPlusKeysTimer.Time(func() {
		userInfo, err = k.delegate.LoadUserPlusKeys(
			ctx, uid, pollForKID, offline)
	})
	return userInfo, err
}
337493
func WithMSPPkg(msp sdkApi.MSPProviderFactory) Option {
	return func(opts *options) error {
		opts.MSP = msp
		return nil
	}
}
561095
func printPackage(pkg *Package) {
	if len(pkg.Enums) > 0 {
		logf("loaded %d enums:", len(pkg.Enums))
		for k, enum := range pkg.Enums {
			logf(" - enum #%d\t%+v", k, enum)
		}
	}
	if len(pkg.Unions) > 0 {
		logf("loaded %d unions:", len(pkg.Unions))
		for k, union := range pkg.Unions {
			logf(" - union #%d\t%+v", k, union)
		}
	}
	if len(pkg.Types) > 0 {
		logf("loaded %d types:", len(pkg.Types))
		for _, typ := range pkg.Types {
			logf(" - type: %q (%d fields)", typ.Name, len(typ.Fields))
		}
	}
	if len(pkg.Messages) > 0 {
		logf("loaded %d messages:", len(pkg.Messages))
		for _, msg := range pkg.Messages {
			logf(" - message: %q (%d fields)", msg.Name, len(msg.Fields))
		}
	}
	if len(pkg.Services) > 0 {
		logf("loaded %d services:", len(pkg.Services))
		for _, svc := range pkg.Services {
			var info string
			if svc.Stream {
				info = "(STREAM)"
			} else if len(svc.Events) > 0 {
				info = fmt.Sprintf("(EVENTS: %v)", svc.Events)
			}
			logf(" - service: %q -> %q %s", svc.RequestType, svc.ReplyType, info)
		}
	}
}
628780
func (c *Config) LoadKeyPair() (*tls.Certificate, error) {
	if c.CertFile == "" || c.KeyFile == "" {
		return nil, nil
	}

	if c.KeyLoader == nil {
		return nil, fmt.Errorf("No Keyloader object to perform LoadKeyPair")
	}

	cert, err := c.KeyLoader.LoadKeyPair(c.CertFile, c.KeyFile)
	if err != nil {
		return nil, fmt.Errorf("Failed to load cert/key pair: %v", err)
	}
	return cert, err
}
500813
func LoadPackagedKeypair(name string) (cert tls.Certificate, certFile, keyFile string, err error) {
	certFile, err = LocatePackagedPEMFile(name + "-cert")
	if err != nil {
		return
	}
	keyFile, err = LocatePackagedPEMFile(name + "-key")
	if err != nil {
		return
	}
	cert, err = tls.LoadX509KeyPair(certFile, keyFile)
	return
}
273124
func getPkgPath(c io.Closer) (name string, pkgPath string) {
	t := reflect.TypeOf(c)
	if t.Kind() == reflect.Ptr {
		t = t.Elem()
	}
	return t.Name(), t.PkgPath()
}
518198
func Package(path string, files []string) (*PkgInfo, error) {
	start := time.Now()
	defer func() {
		debug.Println("time parse Magefiles:", time.Since(start))
	}()
	fset := token.NewFileSet()
	pkg, err := getPackage(path, files, fset)
	if err != nil {
		return nil, err
	}
	p := doc.New(pkg, "./", 0)
	pi := &PkgInfo{
		AstPkg:      pkg,
		DocPkg:      p,
		Description: toOneLine(p.Doc),
	}

	setNamespaces(pi)
	setFuncs(pi)

	hasDupes, names := checkDupeTargets(pi)
	if hasDupes {
		msg := "Build targets must be case insensitive, thus the following targets conflict:\n"
		for _, v := range names {
			if len(v) > 1 {
				msg += "  " + strings.Join(v, ", ") + "\n"
			}
		}
		return nil, errors.New(msg)
	}

	return pi, nil
}
640606
func (c *NodeupModelContext) BuildPKIKubeconfig(name string) (string, error) {
	ca, err := c.FindCert(fi.CertificateId_CA)
	if err != nil {
		return "", err
	}

	cert, err := c.FindCert(name)
	if err != nil {
		return "", err
	}

	key, err := c.FindPrivateKey(name)
	if err != nil {
		return "", err
	}

	return c.BuildKubeConfig(name, ca, cert, key)
}
207487
func LoadFunctionMap() FunctionMap {
	fm := make(FunctionMap)

	fm.AddFunction("keyMatch", util.KeyMatchFunc)
	fm.AddFunction("keyMatch2", util.KeyMatch2Func)
	fm.AddFunction("regexMatch", util.RegexMatchFunc)
	fm.AddFunction("ipMatch", util.IPMatchFunc)

	return fm
}
387005
func (p *ChannelPackager) LoadFwdPkgs(tx *bbolt.Tx) ([]*FwdPkg, error) {
	return loadChannelFwdPkgs(tx, p.source)
}
382114
func LoadRSAKeyPairPackage(data []byte) (public crypto.PublicKey, private crypto.PrivateKey, err error) {
	firstblock, rest := pem.Decode(data)
	if firstblock == nil {
		return nil, nil, ErrBadKeysFile
	}
	privatekey, err := RSAPrivateKeyFromPEM(pem.EncodeToMemory(firstblock))
	if err != nil {
		return nil, nil, err
	}
	secondblock, _ := pem.Decode(rest)
	if secondblock == nil {
		return nil, nil, ErrBadKeysFile
	}
	publickey, err := RSAPublicKeyFromPEM(pem.EncodeToMemory(secondblock))
	if err != nil {
		return nil, nil, err
	}
	return publickey, privatekey, nil
}
439036
func (r *Registry) packageIdentityName(f *descriptor.FileDescriptorProto) string {
	if f.Options != nil && f.Options.GoPackage != nil {
		gopkg := f.Options.GetGoPackage()
		idx := strings.LastIndex(gopkg, "/")
		if idx < 0 {
			gopkg = gopkg[idx+1:]
		}

		gopkg = gopkg[idx+1:]
		// package name is overrided with the string after the
		// ';' character
		sc := strings.IndexByte(gopkg, ';')
		if sc < 0 {
			return sanitizePackageName(gopkg)

		}
		return sanitizePackageName(gopkg[sc+1:])
	}
	if p := r.importPath; len(p) != 0 {
		if i := strings.LastIndex(p, "/"); i >= 0 {
			p = p[i+1:]
		}
		return p
	}

	if f.Package == nil {
		base := filepath.Base(f.GetName())
		ext := filepath.Ext(base)
		return strings.TrimSuffix(base, ext)
	}
	return f.GetPackage()
}
1146883
func (g *Generator) SetPkg(name, path string) {
	g.pkgName = name
	g.pkgPath = path
}
659371
func parsePKGBUILD(input string) (*PKGBUILD, error) {
	pkgb, err := parse(input)
	if err != nil {
		return nil, err
	}

	if !validPkgver(string(pkgb.Pkgver)) {
		return nil, fmt.Errorf("invalid pkgver: %s", pkgb.Pkgver)
	}

	if len(pkgb.Arch) == 0 {
		return nil, fmt.Errorf("Arch missing")
	}

	if len(pkgb.Pkgnames) == 0 {
		return nil, fmt.Errorf("missing pkgname")
	}

	for _, name := range pkgb.Pkgnames {
		if !validPkgname(name) {
			return nil, fmt.Errorf("invalid pkgname: %s", name)
		}
	}

	return pkgb, nil
}
275177
func (f *Fn) HelperParamList() string {
	return join(f.Params, func(p *Param) string { return p.Name + " " + p.HelperType() }, ", ")
}
57129
func (k *KeyLoader) LoadKeyPair(certFile, keyFile string) (*tls.Certificate, error) {
	k.cacheLock.Lock()
	defer k.cacheLock.Unlock()

	// Allow downgrading
	if certFile == "" && keyFile == "" {
		k.certificate = nil
		return nil, nil
	}

	cert, err := tls.LoadX509KeyPair(certFile, keyFile)
	if err != nil {
		return nil, fmt.Errorf("Failed to load cert/key pair: %v", err)
	}

	k.certificate = &cert
	return k.certificate, nil
}