// Copied from cmd/go/internal/modfile/read.go
438805
func modulePath(mod []byte) string {
	for len(mod) > 0 {
		line := mod
		mod = nil
		if i := bytes.IndexByte(line, '\n'); i >= 0 {
			line, mod = line[:i], line[i+1:]
		}
		if i := bytes.Index(line, slashSlash); i >= 0 {
			line = line[:i]
		}
		line = bytes.TrimSpace(line)
		if !bytes.HasPrefix(line, moduleStr) {
			continue
		}
		line = line[len(moduleStr):]
		n := len(line)
		line = bytes.TrimSpace(line)
		if len(line) == n || len(line) == 0 {
			continue
		}

		if line[0] == '"' || line[0] == '`' {
			p, err := strconv.Unquote(string(line))
			if err != nil {
				return "" // malformed quoted string or multiline module path
			}
			return p
		}

		return string(line)
	}
	return "" // missing module path
}
1089406
func ReadFile(cfgpath string, debug bool) (*Config, error) {
	content, err := ioutil.ReadFile(cfgpath)
	if err != nil {
		return nil, fmt.Errorf("error reading config file %q: %v", cfgpath, err)
	}
	if debug {
		log.Printf("Config file %q contents:\n%s", cfgpath, content)
	}
	return GetConfig(string(content), debug)
}
114999
func invMod(x *big.Int, p *big.Int) (z *big.Int) {
	z = new(big.Int).ModInverse(x, p)
	return z
}
1022218
func (fs *errorFS) ReadFile(
	ctx context.Context,
	op *fuseops.ReadFileOp) (err error) {
	if fs.transformError(op, &err) {
		return
	}

	if op.Inode != fooInodeID || op.Offset != 0 {
		err = fmt.Errorf("Unexpected request: %#v", op)
		return
	}

	op.BytesRead = copy(op.Dst, FooContents)

	return
}
22101
func (f *StandaloneFile) ReadFile() ([]byte, error) {
	return f.filespace.ReadFile(f.path)
}
1252172
func (fs *Filespace) ReadFile(subPath string) ([]byte, error) {
	return fs.root.ReadFile(subPath)
}
1312037
func (c C) Moddif(y, mod Input) Input {
	var (
		diff    = c.Absdif(y).Modulo(mod)
		modhalf = mod.Mul(C(0.5))
	)
	return modhalf.Add(diff.Absdif(modhalf).Neg())
}
1293754
func ReadGodelConfigFromFile(cfgFile string) (GodelConfig, error) {
	if _, err := os.Stat(cfgFile); os.IsNotExist(err) {
		return GodelConfig{}, nil
	}

	var godelCfg GodelConfig
	bytes, err := ioutil.ReadFile(cfgFile)
	if err != nil {
		return GodelConfig{}, errors.Wrapf(err, "failed to read file %s", cfgFile)
	}
	upgradedBytes, err := UpgradeConfig(bytes)
	if err != nil {
		return GodelConfig{}, errors.Wrapf(err, "failed to upgrade configuration")
	}
	if err := yaml.Unmarshal(upgradedBytes, &godelCfg); err != nil {
		return GodelConfig{}, errors.Wrapf(err, "failed to unmarshal gödel config YAML")
	}
	return godelCfg, nil
}
776818
func ReadFile(f string) (*Schema, error) {
	in, err := os.Open(f)
	if err != nil {
		return nil, err
	}
	defer in.Close()
	return Read(in)
}
659812
func (p *MemFSPath) ReadFile() ([]byte, error) {
	if p.contents == nil {
		return nil, os.ErrNotExist
	}
	// TODO: Copy?
	return p.contents, nil
}
757781
func readCmds(importPath string) []string {
	var (
		glockfile io.ReadCloser
		err       error
	)
	for _, gopath := range gopaths() {
		glockfile, err = os.Open(glockFilename(gopath, importPath))
		if err == nil {
			break
		}
	}
	if err != nil {
		if os.IsNotExist(err) {
			return nil
		}
		perror(err)
	}

	var cmds []string
	var scanner = bufio.NewScanner(glockfile)
	for scanner.Scan() {
		var fields = strings.Fields(scanner.Text())
		if len(fields) != 2 || fields[0] != "cmd" {
			return cmds
		}
		cmds = append(cmds, fields[1])
	}
	if err := scanner.Err(); err != nil {
		perror(err)
	}
	return cmds
}
907144
func (p *Pod) readFile(path string) ([]byte, error) {
	f, err := p.openFile(path, syscall.O_RDONLY)
	if err != nil {
		return nil, err
	}
	defer f.Close()

	return ioutil.ReadAll(f)
}
1165217
func ReadConfigFromFile(path string) (*Config, error) {
	buffer, err := ioutil.ReadFile(path)
	if err != nil {
		return nil, err
	}

	return ReadConfig(buffer)
}
1195304
func (m *moduleMgr) readModuleManifestSnapshot() error {
	r, err := m.FS.Open(m.manifestSnapshotPath())
	if err != nil {
		if os.IsNotExist(err) {
			// We'll treat a missing file as an empty manifest
			m.manifest = make(modsdir.Manifest)
			return nil
		}
		return err
	}

	m.manifest, err = modsdir.ReadManifestSnapshot(r)
	return err
}
391199
func (mr *ModRunner) ReadConfig() error {
	ret, err := ioutil.ReadFile(mr.ConfPath)
	if err != nil {
		return fmt.Errorf("Error reading config file %s: %s", mr.ConfPath, err)
	}
	newcnf, err := conf.Parse(mr.ConfPath, string(ret))
	if err != nil {
		return fmt.Errorf("Error reading config file %s: %s", mr.ConfPath, err)
	}

	if _, err := shell.GetShellName(newcnf.GetVariables()[shellVarName]); err != nil {
		return err
	}

	newcnf.CommonExcludes(CommonExcludes)
	mr.Config = newcnf
	return nil
}
57166
func ModGet(xu *xgbutil.XUtil, keycode xproto.Keycode) uint16 {
	modMap := ModMapGet(xu)

	var i byte
	for i = 0; int(i) < len(modMap.Keycodes); i++ {
		if modMap.Keycodes[i] == keycode {
			return Modifiers[i/modMap.KeycodesPerModifier]
		}
	}
	return 0
}
667462
func getModTime(path string) (t time.Time, err error) {
	// Convert to absolute path
	absPath, err := filepath.Abs(path)
	if err != nil {
		return t, fmt.Errorf("Unable to get absolute path of %s. %s", path, err)
	}

	// Version is minio non-standard, we will use minio binary's
	// ModTime as release time.
	fi, err := os.Stat(absPath)
	if err != nil {
		return t, fmt.Errorf("Unable to get ModTime of %s. %s", absPath, err)
	}

	// Return the ModTime
	return fi.ModTime().UTC(), nil
}