// gofmt applies "gofmt -s" to the content of the buffer.
421868
func gofmt(blob []byte) ([]byte, error) {
	out := bytes.Buffer{}
	cmd := exec.Command("gofmt", "-s")
	cmd.Stdin = bytes.NewReader(blob)
	cmd.Stdout = &out
	cmd.Stderr = os.Stderr
	if err := cmd.Run(); err != nil {
		return nil, err
	}
	return out.Bytes(), nil
}
1281392
func (g *Group) Buffered() int {
	g.mtx.Lock()
	defer g.mtx.Unlock()
	return g.headBuf.Buffered()
}
481187
func htmlFmt(w io.Writer, format string, x ...interface{}) string {
	writeAny(w, true, x[0])
	return ""
}
762183
func printFmt(l, v string, args ...interface{}) {
	l = label(l, subIndent, valIndent)
	fmt.Printf("%s %s\n", l, fmt.Sprintf(v, args...))
}
1141913
func (flb FilteredBuffer) LineAt(i int) (line.Line, error) {
	if i >= len(flb.selection) {
		return nil, errors.Errorf("specified index %d is out of range", len(flb.selection))
	}
	return flb.src.LineAt(flb.selection[i])
}
205193
func format(f *os.File) {
	// Run go fmt on the file.
	cmd := exec.Command("go", "fmt")
	cmd.Stdin = f
	_ = cmd.Run()
}
732200
func FuzzSmat(data []byte) int {
	return smat.Fuzz(&smatContext{}, smat.ActionID('S'), smat.ActionID('T'),
		smatActionMap, data)
}
456491
func GoLeftWord(buf *Buffer) {
	buf.CursorLeft(len([]rune(buf.Document().TextBeforeCursor())) - buf.Document().FindStartOfPreviousWordWithSpace())
}
768799
func (cmd *baseCommand) WriteUint32At(num uint32, index int) (int, error) {
	binary.BigEndian.PutUint32(cmd.dataBuffer[index:index+4], num)
	return 4, nil
}
800497
func (c *MemoryStore) MGet(keys []string) (map[string]interface{}, error) {
	results := make(map[string]interface{}, len(keys))
	for _, key := range keys {
		item, _ := c.Get(key)
		results[key] = item
	}
	return results, nil
}
1166095
func gofmt(src []byte) []byte {
	formatted, err := format.Source(src)
	if err != nil {
		// Should never happen, but can arise when developing this code.
		// The user can compile the output to see the error.
		log.Printf("warning: internal error: invalid Go generated: %s", err)
		log.Printf("warning: compile the package to analyze the error")
		return src
	}
	return formatted
}
1020208
func formatBytes(i int64) (result string) {
	var n float64
	sFmt, eFmt := "%.01f", ""
	switch {
	case i > EB:
		eFmt = "E"
		n = float64(i) / float64(EB)
	case i > PB:
		eFmt = "P"
		n = float64(i) / float64(PB)
	case i > TB:
		eFmt = "T"
		n = float64(i) / float64(TB)
	case i > GB:
		eFmt = "G"
		n = float64(i) / float64(GB)
	case i > MB:
		eFmt = "M"
		n = float64(i) / float64(MB)
	case i > KB:
		eFmt = "K"
		n = float64(i) / float64(KB)
	default:
		sFmt = "%.0f"
		n = float64(i)
	}
	if eFmt != "" && n >= 10 {
		sFmt = "%.0f"
	}
	result = fmt.Sprintf(sFmt+eFmt, n)
	result = strings.Trim(result, " ")
	return
}
1192630
func (c *T) AppendFeRTMTo(aggregate *memmetrics.RTMetrics) error {
	c.mu.Lock()
	defer c.mu.Unlock()

	return aggregate.Append(c.rtm)
}
839979
func GMapGet(key string) (interface{}, bool) {
	gmap.lock.Lock()
	defer gmap.lock.Unlock()

	if !checkGMap(false) {
		return nil, false
	}

	v, ok := gmap.gm[key]
	return v, ok
}
1164968
func (f FakeFile) ReadAt(p []byte, off int64) (n int, err error) {
	return f.Buffer.ReadAt(p, off)
}
212528
func (file *File) WriteAt(buf []byte, offset int64) (int, error) {
	return file.Fid.Clnt.Write(file.Fid, buf, uint64(offset))
}
539286
func Fmt(ps string) string {
	ps = fmtReg1.ReplaceAllString(ps, "")
	return fmtReg2.ReplaceAllString(ps, "|")
}