You are an expert in writing code in many different languages. Your goal is to perform code completion for the following code, keeping in mind the rest of the code and the file meta data.
    Metadata details:
    filename: status_local_file_retrieval.go
    path of file: ./repos/cockroach/pkg/server
    
    the code of the file until where you have to start completion: // Copyright 2021 The Cockroach Authors.
//
// Use of this software is governed by the Business Source License
// included in the file licenses/BSL.txt.
//
// As of the Change Date specified in that file, in accordance with
// the Business Source License, use of this software will be governed
// by the Apache License, Version 2.0, included in the file
// licenses/APL.txt.

package server

import (
	"bytes"
	"context"
	"fmt"
	"os"
	"path/filepath"
	"runtime/pprof"
	"str
    
func stacksLocal(req *serverpb.StacksRequest) (*serverpb.JSONResponse, error) {
	var buf *bytes.Buffer
	switch req.Type {
	case serverpb.StacksType_GOROUTINE_STACKS:
		// Use allstacks.Get because it doesn't have an arbitrary 64MB limit (as
		// opposed to the profile).
		buf = bytes.NewBuffer(allstacks.Get())
	case serverpb.StacksType_GOROUTINE_STACKS_DEBUG_1:
		buf = bytes.NewBuffer(nil)
		if err := pprof.Lookup("goroutine").WriteTo(buf, 1 /* debug */); err != nil {
			return nil, status.Errorf(codes.Unknown, "failed to write goroutine stack: %s", err)
		}
	default:
		return nil, status.Errorf(codes.InvalidArgument, "unknown stacks type: %s", req.Type)
	}
	return &serverpb.JSONResponse{Data: buf.Bytes()}, nil
}