// Copyright 2018 The Go Authors. All rights reserved.// Use of this source code is governed by a BSD-style// license that can be found in the LICENSE file.package errorsimport ()// A Frame contains part of a call stack.typeFramestruct {// Make room for three PCs: the one we were asked for, what it called, // and possibly a PC for skipPleaseUseCallersFrames. See: // https://go.googlesource.com/go/+/032678e0fb/src/runtime/extern.go#169frames [3]uintptr}// Caller returns a Frame that describes a frame on the caller's stack.// The argument skip is the number of frames to skip over.// Caller(0) returns the frame for the caller of Caller.func ( int) Frame {varFrameruntime.Callers(+1, .frames[:])return}// Location reports the file, line, and function of a frame.//// The returned function may be "" even if file and line are not.func ( Frame) () (, string, int) { := runtime.CallersFrames(.frames[:])if , := .Next(); ! {return"", "", 0 } , := .Next()if ! {return"", "", 0 }return .Function, .File, .Line}// Format prints the stack as error detail.// It should be called from an error's Format implementation// after printing any other error detail.func ( Frame) ( Printer) {if .Detail() { , , := .Location()if != "" { .Printf("%s\n ", ) }if != "" { .Printf("%s:%d\n", , ) } }}
The pages are generated with Goldsv0.6.7. (GOOS=linux GOARCH=amd64)
Golds is a Go 101 project developed by Tapir Liu.
PR and bug reports are welcome and can be submitted to the issue list.
Please follow @Go100and1 (reachable from the left QR code) to get the latest news of Golds.