func NewStacktrace(skip int, context int, appPackagePrefixes []string) *Stacktrace {
	var frames []*StacktraceFrame
	for i := 1 + skip; ; i++ {
		pc, file, line, ok := runtime.Caller(i)
		if !ok {
			break
		}
		frame := NewStacktraceFrame(pc, file, line, context, appPackagePrefixes)
		if frame != nil {
			frames = append(frames, frame)
		}
	}
	if len(frames) == 0 {
		return nil
	}
	if len(frames) == 1 {
		return &Stacktrace{frames}
	}
	for i, j := 0, len(frames)-1; i < j; i, j = i+1, j-1 {
		frames[i], frames[j] = frames[j], frames[i]
	}
	return &Stacktrace{frames}
}
Intialize and populate a new stacktrace, skipping skip frames.

context is the number of surrounding lines that should be included for context.
Setting context to 3 would try to get seven lines. Setting context to -1 returns
one line with no surrounding context, and 0 returns no context.

appPackagePrefixes is a list of prefixes used to check whether a package should
be considered "in app".
package raven
import (
	"bytes"
	"go/build"
	"io/ioutil"
	"path/filepath"
	"runtime"
	"strings"
	"sync"
	"github.com/pkg/errors"
)
type Stacktrace struct {
	Frames []*StacktraceFrame `json:"frames"`
}
func (s *Stacktrace) Class() string { return "stacktrace" }
func (s *Stacktrace) Culprit() string {
	for i := len(s.Frames) - 1; i >= 0; i-- {
		frame := s.Frames[i]
		if frame.InApp == true && frame.Module != "" && frame.Function != "" {
			return frame.Module + "." + frame.Function
		}
	}
	return ""
}
type StacktraceFrame struct {
	Filename string `json:"filename,omitempty"`
	Function string `json:"function,omitempty"`
	Module   string `json:"module,omitempty"`
	Lineno       int      `json:"lineno,omitempty"`
	Colno        int      `json:"colno,omitempty"`
	AbsolutePath string   `json:"abs_path,omitempty"`
	ContextLine  string   `json:"context_line,omitempty"`
	PreContext   []string `json:"pre_context,omitempty"`
	PostContext  []string `json:"post_context,omitempty"`
	InApp        bool     `json:"in_app"`
}
func GetOrNewStacktrace(err error, skip int, context int, appPackagePrefixes []string) *Stacktrace {
	stacktracer, errHasStacktrace := err.(interface {
		StackTrace() errors.StackTrace
	})
	if errHasStacktrace {
		var frames []*StacktraceFrame
		for _, f := range stacktracer.StackTrace() {
			pc := uintptr(f) - 1
			fn := runtime.FuncForPC(pc)
			var file string
			var line int
			if fn != nil {
				file, line = fn.FileLine(pc)
			} else {
				file = "unknown"
			}
			frame := NewStacktraceFrame(pc, file, line, context, appPackagePrefixes)
			if frame != nil {
				frames = append([]*StacktraceFrame{frame}, frames...)
			}
		}
		return &Stacktrace{Frames: frames}
	} else {
		return NewStacktrace(skip + 1, context, appPackagePrefixes)
	}
}