1
0
mirror of https://github.com/ceph/ceph-csi.git synced 2025-06-14 18:53:35 +00:00

build: move e2e dependencies into e2e/go.mod

Several packages are only used while running the e2e suite. These
packages are less important to update, as the they can not influence the
final executable that is part of the Ceph-CSI container-image.

By moving these dependencies out of the main Ceph-CSI go.mod, it is
easier to identify if a reported CVE affects Ceph-CSI, or only the
testing (like most of the Kubernetes CVEs).

Signed-off-by: Niels de Vos <ndevos@ibm.com>
This commit is contained in:
Niels de Vos
2025-03-04 08:57:28 +01:00
committed by mergify[bot]
parent 15da101b1b
commit bec6090996
8047 changed files with 1407827 additions and 3453 deletions
Makefile
e2e
go.modgo.sum
vendor
cel.dev
github.com
JeffAshton
Microsoft
NYTimes
antlr4-go
asaskevich
beorn7
blang
cenkalti
ceph
ceph-csi
cespare
containerd
coreos
cyphar
davecgh
distribution
docker
emicklei
euank
go-kmsg-parser
felixge
fsnotify
fxamacker
go-logr
go-openapi
go-task
godbus
gogo
golang
google
btree
cadvisor
cel-go
LICENSE
cel
checker
common
ext
interpreter
parser
gnostic-models
go-cmp
gofuzz
pprof
uuid
gorilla
grpc-ecosystem
inconshreveable
josharian
json-iterator
karrick
klauspost
kubernetes-csi
kylelemons
godebug
mailru
mistifyio
moby
modern-go
munnerz
mxk
onsi
ginkgo
v2
.gitignoreCHANGELOG.mdCONTRIBUTING.mdLICENSEMakefileREADME.mdRELEASING.md
config
core_dsl.godecorator_dsl.godeprecated_dsl.go
formatter
ginkgo
ginkgo_cli_dependencies.goginkgo_t_dsl.go
internal
reporters
reporting_dsl.gotable_dsl.go
types
gomega
.gitignoreCHANGELOG.mdCONTRIBUTING.mdLICENSEREADME.mdRELEASING.md
format
gcustom
gomega_dsl.go
internal
matchers.go
matchers
types
opencontainers
pkg
prometheus
client_golang
client_model
common
procfs
sirupsen
spf13
stoewer
x448
go.etcd.io
go.opentelemetry.io
auto
contrib
otel
.codespellignore.codespellrc.gitattributes.gitignore.golangci.yml.lycheeignore.markdownlint.yamlCHANGELOG.mdCODEOWNERSCONTRIBUTING.mdLICENSEMakefileREADME.mdRELEASING.mdVERSIONING.md
attribute
baggage
codes
doc.goerror_handler.go
exporters
get_main_pkgs.shhandler.go
internal
internal_logging.gometric.go
metric
propagation.go
propagation
renovate.jsonrequirements.txt
sdk
semconv
trace.go
trace
verify_readmes.shverify_released_changelog.shversion.goversions.yaml
proto
go.uber.org
golang.org
x
crypto
exp
net
oauth2
sync
sys
LICENSEPATENTS
cpu
plan9
unix
.gitignoreREADME.mdaffinity_linux.goaliases.goasm_aix_ppc64.sasm_bsd_386.sasm_bsd_amd64.sasm_bsd_arm.sasm_bsd_arm64.sasm_bsd_ppc64.sasm_bsd_riscv64.sasm_linux_386.sasm_linux_amd64.sasm_linux_arm.sasm_linux_arm64.sasm_linux_loong64.sasm_linux_mips64x.sasm_linux_mipsx.sasm_linux_ppc64x.sasm_linux_riscv64.sasm_linux_s390x.sasm_openbsd_mips64.sasm_solaris_amd64.sasm_zos_s390x.sauxv.goauxv_unsupported.gobluetooth_linux.gobpxsvc_zos.gobpxsvc_zos.scap_freebsd.goconstants.godev_aix_ppc.godev_aix_ppc64.godev_darwin.godev_dragonfly.godev_freebsd.godev_linux.godev_netbsd.godev_openbsd.godev_zos.godirent.goendian_big.goendian_little.goenv_unix.gofcntl.gofcntl_darwin.gofcntl_linux_32bit.gofdset.gogccgo.gogccgo_c.cgccgo_linux_amd64.goifreq_linux.goioctl_linux.goioctl_signed.goioctl_unsigned.goioctl_zos.gomkall.shmkerrors.shmmap_nomremap.gomremap.gopagesize_unix.gopledge_openbsd.goptrace_darwin.goptrace_ios.gorace.gorace0.goreaddirent_getdents.goreaddirent_getdirentries.gosockcmsg_dragonfly.gosockcmsg_linux.gosockcmsg_unix.gosockcmsg_unix_other.gosockcmsg_zos.gosymaddr_zos_s390x.ssyscall.gosyscall_aix.gosyscall_aix_ppc.gosyscall_aix_ppc64.gosyscall_bsd.gosyscall_darwin.gosyscall_darwin_amd64.gosyscall_darwin_arm64.gosyscall_darwin_libSystem.gosyscall_dragonfly.gosyscall_dragonfly_amd64.gosyscall_freebsd.gosyscall_freebsd_386.gosyscall_freebsd_amd64.gosyscall_freebsd_arm.gosyscall_freebsd_arm64.gosyscall_freebsd_riscv64.gosyscall_hurd.gosyscall_hurd_386.gosyscall_illumos.gosyscall_linux.gosyscall_linux_386.gosyscall_linux_alarm.gosyscall_linux_amd64.gosyscall_linux_amd64_gc.gosyscall_linux_arm.gosyscall_linux_arm64.gosyscall_linux_gc.gosyscall_linux_gc_386.gosyscall_linux_gc_arm.gosyscall_linux_gccgo_386.gosyscall_linux_gccgo_arm.gosyscall_linux_loong64.gosyscall_linux_mips64x.gosyscall_linux_mipsx.gosyscall_linux_ppc.gosyscall_linux_ppc64x.gosyscall_linux_riscv64.gosyscall_linux_s390x.gosyscall_linux_sparc64.gosyscall_netbsd.gosyscall_netbsd_386.gosyscall_netbsd_amd64.gosyscall_netbsd_arm.gosyscall_netbsd_arm64.gosyscall_openbsd.gosyscall_openbsd_386.gosyscall_openbsd_amd64.gosyscall_openbsd_arm.gosyscall_openbsd_arm64.gosyscall_openbsd_libc.gosyscall_openbsd_mips64.gosyscall_openbsd_ppc64.gosyscall_openbsd_riscv64.gosyscall_solaris.gosyscall_solaris_amd64.gosyscall_unix.gosyscall_unix_gc.gosyscall_unix_gc_ppc64x.gosyscall_zos_s390x.gosysvshm_linux.gosysvshm_unix.gosysvshm_unix_other.gotimestruct.gounveil_openbsd.govgetrandom_linux.govgetrandom_unsupported.goxattr_bsd.gozerrors_aix_ppc.gozerrors_aix_ppc64.gozerrors_darwin_amd64.gozerrors_darwin_arm64.gozerrors_dragonfly_amd64.gozerrors_freebsd_386.gozerrors_freebsd_amd64.gozerrors_freebsd_arm.gozerrors_freebsd_arm64.gozerrors_freebsd_riscv64.gozerrors_linux.gozerrors_linux_386.gozerrors_linux_amd64.gozerrors_linux_arm.gozerrors_linux_arm64.gozerrors_linux_loong64.gozerrors_linux_mips.gozerrors_linux_mips64.gozerrors_linux_mips64le.gozerrors_linux_mipsle.gozerrors_linux_ppc.gozerrors_linux_ppc64.gozerrors_linux_ppc64le.gozerrors_linux_riscv64.gozerrors_linux_s390x.gozerrors_linux_sparc64.gozerrors_netbsd_386.gozerrors_netbsd_amd64.gozerrors_netbsd_arm.gozerrors_netbsd_arm64.gozerrors_openbsd_386.gozerrors_openbsd_amd64.gozerrors_openbsd_arm.gozerrors_openbsd_arm64.gozerrors_openbsd_mips64.gozerrors_openbsd_ppc64.gozerrors_openbsd_riscv64.gozerrors_solaris_amd64.gozerrors_zos_s390x.gozptrace_armnn_linux.gozptrace_linux_arm64.gozptrace_mipsnn_linux.gozptrace_mipsnnle_linux.gozptrace_x86_linux.gozsymaddr_zos_s390x.szsyscall_aix_ppc.gozsyscall_aix_ppc64.gozsyscall_aix_ppc64_gc.gozsyscall_aix_ppc64_gccgo.gozsyscall_darwin_amd64.gozsyscall_darwin_amd64.szsyscall_darwin_arm64.gozsyscall_darwin_arm64.szsyscall_dragonfly_amd64.gozsyscall_freebsd_386.gozsyscall_freebsd_amd64.gozsyscall_freebsd_arm.gozsyscall_freebsd_arm64.gozsyscall_freebsd_riscv64.gozsyscall_illumos_amd64.gozsyscall_linux.gozsyscall_linux_386.gozsyscall_linux_amd64.gozsyscall_linux_arm.gozsyscall_linux_arm64.gozsyscall_linux_loong64.gozsyscall_linux_mips.gozsyscall_linux_mips64.gozsyscall_linux_mips64le.gozsyscall_linux_mipsle.gozsyscall_linux_ppc.gozsyscall_linux_ppc64.gozsyscall_linux_ppc64le.gozsyscall_linux_riscv64.gozsyscall_linux_s390x.gozsyscall_linux_sparc64.gozsyscall_netbsd_386.gozsyscall_netbsd_amd64.gozsyscall_netbsd_arm.gozsyscall_netbsd_arm64.gozsyscall_openbsd_386.gozsyscall_openbsd_386.szsyscall_openbsd_amd64.gozsyscall_openbsd_amd64.szsyscall_openbsd_arm.gozsyscall_openbsd_arm.szsyscall_openbsd_arm64.gozsyscall_openbsd_arm64.szsyscall_openbsd_mips64.gozsyscall_openbsd_mips64.szsyscall_openbsd_ppc64.gozsyscall_openbsd_ppc64.szsyscall_openbsd_riscv64.gozsyscall_openbsd_riscv64.szsyscall_solaris_amd64.gozsyscall_zos_s390x.gozsysctl_openbsd_386.gozsysctl_openbsd_amd64.gozsysctl_openbsd_arm.gozsysctl_openbsd_arm64.gozsysctl_openbsd_mips64.gozsysctl_openbsd_ppc64.gozsysctl_openbsd_riscv64.gozsysnum_darwin_amd64.gozsysnum_darwin_arm64.gozsysnum_dragonfly_amd64.gozsysnum_freebsd_386.gozsysnum_freebsd_amd64.gozsysnum_freebsd_arm.gozsysnum_freebsd_arm64.gozsysnum_freebsd_riscv64.gozsysnum_linux_386.gozsysnum_linux_amd64.gozsysnum_linux_arm.gozsysnum_linux_arm64.gozsysnum_linux_loong64.gozsysnum_linux_mips.gozsysnum_linux_mips64.gozsysnum_linux_mips64le.gozsysnum_linux_mipsle.gozsysnum_linux_ppc.gozsysnum_linux_ppc64.gozsysnum_linux_ppc64le.gozsysnum_linux_riscv64.gozsysnum_linux_s390x.gozsysnum_linux_sparc64.gozsysnum_netbsd_386.gozsysnum_netbsd_amd64.gozsysnum_netbsd_arm.gozsysnum_netbsd_arm64.gozsysnum_openbsd_386.gozsysnum_openbsd_amd64.gozsysnum_openbsd_arm.gozsysnum_openbsd_arm64.gozsysnum_openbsd_mips64.gozsysnum_openbsd_ppc64.gozsysnum_openbsd_riscv64.gozsysnum_zos_s390x.goztypes_aix_ppc.goztypes_aix_ppc64.goztypes_darwin_amd64.goztypes_darwin_arm64.goztypes_dragonfly_amd64.goztypes_freebsd_386.goztypes_freebsd_amd64.goztypes_freebsd_arm.goztypes_freebsd_arm64.goztypes_freebsd_riscv64.goztypes_linux.goztypes_linux_386.goztypes_linux_amd64.goztypes_linux_arm.goztypes_linux_arm64.goztypes_linux_loong64.goztypes_linux_mips.goztypes_linux_mips64.goztypes_linux_mips64le.goztypes_linux_mipsle.goztypes_linux_ppc.goztypes_linux_ppc64.goztypes_linux_ppc64le.goztypes_linux_riscv64.goztypes_linux_s390x.goztypes_linux_sparc64.goztypes_netbsd_386.goztypes_netbsd_amd64.goztypes_netbsd_arm.goztypes_netbsd_arm64.goztypes_openbsd_386.goztypes_openbsd_amd64.goztypes_openbsd_arm.goztypes_openbsd_arm64.goztypes_openbsd_mips64.goztypes_openbsd_ppc64.goztypes_openbsd_riscv64.goztypes_solaris_amd64.goztypes_zos_s390x.go
windows
term
text
time
tools
google.golang.org
genproto
grpc
AUTHORSCODE-OF-CONDUCT.mdCONTRIBUTING.mdGOVERNANCE.mdLICENSEMAINTAINERS.mdMakefileNOTICE.txtREADME.mdSECURITY.md
attributes
backoff.go
backoff
balancer
balancer_wrapper.go
binarylog
grpc_binarylog_v1
call.go
channelz
clientconn.gocodec.go
codes
connectivity
credentials
dialoptions.godoc.go
encoding
experimental
grpclog
health
interceptor.go
internal
keepalive
mem
metadata
peer
picker_wrapper.gopreloader.go
resolver
resolver_wrapper.gorpc_util.goserver.goservice_config.go
serviceconfig
stats
status
stream.gostream_interfaces.go
tap
trace.gotrace_notrace.gotrace_withtrace.goversion.go
protobuf
LICENSEPATENTS
encoding
internal
descfmt
descopts
detrand
editiondefaults
editionssupport
encoding
errors
filedesc
filetype
flags
genid
impl
order
pragma
protolazy
set
strs
version
proto
protoadapt
reflect
runtime
types
descriptorpb
dynamicpb
gofeaturespb
known
anypb
durationpb
emptypb
fieldmaskpb
structpb
timestamppb
wrapperspb
gopkg.in
k8s.io
api
LICENSE
admission
admissionregistration
apidiscovery
apiserverinternal
apps
authentication
authorization
autoscaling
batch
certificates
coordination
core
discovery
events
extensions
flowcontrol
imagepolicy
networking
node
policy
rbac
resource
scheduling
storage
storagemigration
apiextensions-apiserver
apimachinery
LICENSE
pkg
api
apis
conversion
fields
labels
runtime
selection
types
util
version
watch
third_party
apiserver
LICENSE
pkg
admission
attributes.goaudit.gochain.goconfig.go
configuration
conversion.godecorator.goerrors.gohandler.go
initializer
interfaces.go
metrics
plugin
plugins.goreinvocation.goutil.go
apis
audit
authentication
authorization
cel
endpoints
features
quota
registry
server
storage
storageversion
util
warning
plugin
pkg
audit
authenticator
authorizer
client-go
LICENSE
applyconfigurations
OWNERS
admissionregistration
apiserverinternal
apps
autoscaling
v1
v2
v2beta1
v2beta2
batch
certificates
coordination
core
v1
affinity.goapparmorprofile.goattachedvolume.goawselasticblockstorevolumesource.goazurediskvolumesource.goazurefilepersistentvolumesource.goazurefilevolumesource.gocapabilities.gocephfspersistentvolumesource.gocephfsvolumesource.gocinderpersistentvolumesource.gocindervolumesource.goclientipconfig.goclustertrustbundleprojection.gocomponentcondition.gocomponentstatus.goconfigmap.goconfigmapenvsource.goconfigmapkeyselector.goconfigmapnodeconfigsource.goconfigmapprojection.goconfigmapvolumesource.gocontainer.gocontainerimage.gocontainerport.gocontainerresizepolicy.gocontainerstate.gocontainerstaterunning.gocontainerstateterminated.gocontainerstatewaiting.gocontainerstatus.gocontaineruser.gocsipersistentvolumesource.gocsivolumesource.godaemonendpoint.godownwardapiprojection.godownwardapivolumefile.godownwardapivolumesource.goemptydirvolumesource.goendpointaddress.goendpointport.goendpoints.goendpointsubset.goenvfromsource.goenvvar.goenvvarsource.goephemeralcontainer.goephemeralcontainercommon.goephemeralvolumesource.goevent.goeventseries.goeventsource.goexecaction.gofcvolumesource.goflexpersistentvolumesource.goflexvolumesource.goflockervolumesource.gogcepersistentdiskvolumesource.gogitrepovolumesource.goglusterfspersistentvolumesource.goglusterfsvolumesource.gogrpcaction.gohostalias.gohostip.gohostpathvolumesource.gohttpgetaction.gohttpheader.goimagevolumesource.goiscsipersistentvolumesource.goiscsivolumesource.gokeytopath.golifecycle.golifecyclehandler.golimitrange.golimitrangeitem.golimitrangespec.golinuxcontaineruser.goloadbalanceringress.goloadbalancerstatus.golocalobjectreference.golocalvolumesource.gomodifyvolumestatus.gonamespace.gonamespacecondition.gonamespacespec.gonamespacestatus.gonfsvolumesource.gonode.gonodeaddress.gonodeaffinity.gonodecondition.gonodeconfigsource.gonodeconfigstatus.gonodedaemonendpoints.gonodefeatures.gonoderuntimehandler.gonoderuntimehandlerfeatures.gonodeselector.gonodeselectorrequirement.gonodeselectorterm.gonodespec.gonodestatus.gonodesysteminfo.goobjectfieldselector.goobjectreference.gopersistentvolume.gopersistentvolumeclaim.gopersistentvolumeclaimcondition.gopersistentvolumeclaimspec.gopersistentvolumeclaimstatus.gopersistentvolumeclaimtemplate.gopersistentvolumeclaimvolumesource.gopersistentvolumesource.gopersistentvolumespec.gopersistentvolumestatus.gophotonpersistentdiskvolumesource.gopod.gopodaffinity.gopodaffinityterm.gopodantiaffinity.gopodcondition.gopoddnsconfig.gopoddnsconfigoption.gopodip.gopodos.gopodreadinessgate.gopodresourceclaim.gopodresourceclaimstatus.gopodschedulinggate.gopodsecuritycontext.gopodspec.gopodstatus.gopodtemplate.gopodtemplatespec.goportstatus.goportworxvolumesource.gopreferredschedulingterm.goprobe.goprobehandler.goprojectedvolumesource.goquobytevolumesource.gorbdpersistentvolumesource.gorbdvolumesource.goreplicationcontroller.goreplicationcontrollercondition.goreplicationcontrollerspec.goreplicationcontrollerstatus.goresourceclaim.goresourcefieldselector.goresourcehealth.goresourcequota.goresourcequotaspec.goresourcequotastatus.goresourcerequirements.goresourcestatus.goscaleiopersistentvolumesource.goscaleiovolumesource.goscopedresourceselectorrequirement.goscopeselector.goseccompprofile.gosecret.gosecretenvsource.gosecretkeyselector.gosecretprojection.gosecretreference.gosecretvolumesource.gosecuritycontext.goselinuxoptions.goservice.goserviceaccount.goserviceaccounttokenprojection.goserviceport.goservicespec.goservicestatus.gosessionaffinityconfig.gosleepaction.gostorageospersistentvolumesource.gostorageosvolumesource.gosysctl.gotaint.gotcpsocketaction.gotoleration.gotopologyselectorlabelrequirement.gotopologyselectorterm.gotopologyspreadconstraint.gotypedlocalobjectreference.gotypedobjectreference.govolume.govolumedevice.govolumemount.govolumemountstatus.govolumenodeaffinity.govolumeprojection.govolumeresourcerequirements.govolumesource.govspherevirtualdiskvolumesource.goweightedpodaffinityterm.gowindowssecuritycontextoptions.go
discovery
doc.go
events
extensions
flowcontrol
v1
v1beta1
v1beta2
v1beta3
imagepolicy
internal
meta
networking
node
policy
rbac
resource
scheduling
storage
storagemigration
utils.go
discovery
dynamic
features
gentype
informers
admissionregistration
apiserverinternal
apps
autoscaling
batch
certificates
coordination
core
discovery
doc.go
events
extensions
factory.go
flowcontrol
generic.go
internalinterfaces
networking
node
policy
rbac
resource
scheduling
storage
storagemigration
kubernetes
clientset.godoc.go
fake
import.go
scheme
typed
admissionregistration
apiserverinternal
apps
authentication
authorization
autoscaling
batch
certificates
coordination
core
discovery
events
extensions
flowcontrol
networking
node
policy
rbac
resource
scheduling
storage
storagemigration
listers
admissionregistration
apiserverinternal
apps
autoscaling
batch
certificates
coordination
core
discovery
doc.go
events
extensions
flowcontrol
generic_helpers.go
networking
node
policy
rbac
resource
scheduling
storage
storagemigration
openapi
pkg
plugin
pkg
client
rest
restmapper
scale
testing
tools
transport
util
cloud-provider
component-base
LICENSE
cli
config
featuregate
logs
metrics
tracing
version
zpages
component-helpers
LICENSE
node
resource
scheduling
storage
controller-manager
cri-api
cri-client
csi-translation-lib
dynamic-resource-allocation
klog
kms
kube-openapi
kube-scheduler
kubectl
LICENSE
pkg
scale
util
podutils
kubelet
kubernetes
LICENSE
pkg
api
apis
capabilities
client
conditions
cluster
controller
features
fieldpath
kubelet
apis
cadvisor
checkpointmanager
cm
.mockery.yamlOWNERS
admission
cgroup_manager_linux.gocgroup_manager_unsupported.gocgroup_v1_manager_linux.gocgroup_v2_manager_linux.gocontainer_manager.gocontainer_manager_linux.gocontainer_manager_stub.gocontainer_manager_unsupported.gocontainer_manager_windows.go
containermap
cpumanager
devicemanager
doc.go
dra
fake_container_manager.gofake_internal_container_lifecycle.gofake_pod_container_manager.gohelpers.gohelpers_linux.gohelpers_unsupported.gointernal_container_lifecycle.gointernal_container_lifecycle_linux.gointernal_container_lifecycle_unsupported.gointernal_container_lifecycle_windows.go
memorymanager
node_container_manager_linux.gopod_container_manager_linux.gopod_container_manager_stub.goqos_container_manager_linux.go
resourceupdates
topologymanager
types.go
util
config
container
events
eviction
kuberuntime
lifecycle
metrics
pluginmanager
server
metrics
stats
status
types
util
winstats
probe
scheduler
OWNERS
apis
backend
eventhandlers.goextender.go
framework
metrics
profile
schedule_one.goscheduler.go
util
security
securitycontext
util
volume
test
e2e
framework
perftype
storage
testing-manifests
README.md
dra
embed.go
flexvolume
gpu
guestbook
kubectl
podrbd-storage-class.yaml
sample-device-plugin
statefulset
storage-csi
utils
third_party
mount-utils
pod-security-admission
utils
modules.txt
sigs.k8s.io
go.modgo.sum
scripts
vendor
gomodules.xyz
jsonpatch
modules.txt

177
e2e/vendor/github.com/pkg/errors/stack.go generated vendored Normal file

@ -0,0 +1,177 @@
package errors
import (
"fmt"
"io"
"path"
"runtime"
"strconv"
"strings"
)
// Frame represents a program counter inside a stack frame.
// For historical reasons if Frame is interpreted as a uintptr
// its value represents the program counter + 1.
type Frame uintptr
// pc returns the program counter for this frame;
// multiple frames may have the same PC value.
func (f Frame) pc() uintptr { return uintptr(f) - 1 }
// file returns the full path to the file that contains the
// function for this Frame's pc.
func (f Frame) file() string {
fn := runtime.FuncForPC(f.pc())
if fn == nil {
return "unknown"
}
file, _ := fn.FileLine(f.pc())
return file
}
// line returns the line number of source code of the
// function for this Frame's pc.
func (f Frame) line() int {
fn := runtime.FuncForPC(f.pc())
if fn == nil {
return 0
}
_, line := fn.FileLine(f.pc())
return line
}
// name returns the name of this function, if known.
func (f Frame) name() string {
fn := runtime.FuncForPC(f.pc())
if fn == nil {
return "unknown"
}
return fn.Name()
}
// Format formats the frame according to the fmt.Formatter interface.
//
// %s source file
// %d source line
// %n function name
// %v equivalent to %s:%d
//
// Format accepts flags that alter the printing of some verbs, as follows:
//
// %+s function name and path of source file relative to the compile time
// GOPATH separated by \n\t (<funcname>\n\t<path>)
// %+v equivalent to %+s:%d
func (f Frame) Format(s fmt.State, verb rune) {
switch verb {
case 's':
switch {
case s.Flag('+'):
io.WriteString(s, f.name())
io.WriteString(s, "\n\t")
io.WriteString(s, f.file())
default:
io.WriteString(s, path.Base(f.file()))
}
case 'd':
io.WriteString(s, strconv.Itoa(f.line()))
case 'n':
io.WriteString(s, funcname(f.name()))
case 'v':
f.Format(s, 's')
io.WriteString(s, ":")
f.Format(s, 'd')
}
}
// MarshalText formats a stacktrace Frame as a text string. The output is the
// same as that of fmt.Sprintf("%+v", f), but without newlines or tabs.
func (f Frame) MarshalText() ([]byte, error) {
name := f.name()
if name == "unknown" {
return []byte(name), nil
}
return []byte(fmt.Sprintf("%s %s:%d", name, f.file(), f.line())), nil
}
// StackTrace is stack of Frames from innermost (newest) to outermost (oldest).
type StackTrace []Frame
// Format formats the stack of Frames according to the fmt.Formatter interface.
//
// %s lists source files for each Frame in the stack
// %v lists the source file and line number for each Frame in the stack
//
// Format accepts flags that alter the printing of some verbs, as follows:
//
// %+v Prints filename, function, and line number for each Frame in the stack.
func (st StackTrace) Format(s fmt.State, verb rune) {
switch verb {
case 'v':
switch {
case s.Flag('+'):
for _, f := range st {
io.WriteString(s, "\n")
f.Format(s, verb)
}
case s.Flag('#'):
fmt.Fprintf(s, "%#v", []Frame(st))
default:
st.formatSlice(s, verb)
}
case 's':
st.formatSlice(s, verb)
}
}
// formatSlice will format this StackTrace into the given buffer as a slice of
// Frame, only valid when called with '%s' or '%v'.
func (st StackTrace) formatSlice(s fmt.State, verb rune) {
io.WriteString(s, "[")
for i, f := range st {
if i > 0 {
io.WriteString(s, " ")
}
f.Format(s, verb)
}
io.WriteString(s, "]")
}
// stack represents a stack of program counters.
type stack []uintptr
func (s *stack) Format(st fmt.State, verb rune) {
switch verb {
case 'v':
switch {
case st.Flag('+'):
for _, pc := range *s {
f := Frame(pc)
fmt.Fprintf(st, "\n%+v", f)
}
}
}
}
func (s *stack) StackTrace() StackTrace {
f := make([]Frame, len(*s))
for i := 0; i < len(f); i++ {
f[i] = Frame((*s)[i])
}
return f
}
func callers() *stack {
const depth = 32
var pcs [depth]uintptr
n := runtime.Callers(3, pcs[:])
var st stack = pcs[0:n]
return &st
}
// funcname removes the path prefix component of a function's name reported by func.Name().
func funcname(name string) string {
i := strings.LastIndex(name, "/")
name = name[i+1:]
i = strings.Index(name, ".")
return name[i+1:]
}