diff options
author | 2023-01-17 11:25:13 +0000 | |
---|---|---|
committer | 2023-01-17 11:25:13 +0000 | |
commit | a6c6bdb34ab668ab810308e63325a891e404e434 (patch) | |
tree | 12be85a203123dbaa602e8173343c015d5149047 /vendor/codeberg.org/gruf/go-errors/v2/callers.go | |
parent | [bugfix] Parse video metadata more accurately; allow Range in fileserver (#1342) (diff) | |
download | gotosocial-a6c6bdb34ab668ab810308e63325a891e404e434.tar.xz |
[chore]: Bump codeberg.org/gruf/go-errors/v2 from 2.0.2 to 2.1.1 (#1346)
Bumps codeberg.org/gruf/go-errors/v2 from 2.0.2 to 2.1.1.
---
updated-dependencies:
- dependency-name: codeberg.org/gruf/go-errors/v2
dependency-type: direct:production
update-type: version-update:semver-minor
...
Signed-off-by: dependabot[bot] <support@github.com>
Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Diffstat (limited to 'vendor/codeberg.org/gruf/go-errors/v2/callers.go')
-rw-r--r-- | vendor/codeberg.org/gruf/go-errors/v2/callers.go | 34 |
1 files changed, 15 insertions, 19 deletions
diff --git a/vendor/codeberg.org/gruf/go-errors/v2/callers.go b/vendor/codeberg.org/gruf/go-errors/v2/callers.go index 77a2c1c1b..3fe84b0c5 100644 --- a/vendor/codeberg.org/gruf/go-errors/v2/callers.go +++ b/vendor/codeberg.org/gruf/go-errors/v2/callers.go @@ -40,33 +40,29 @@ func (f Callers) Frames() []runtime.Frame { return frames } -// MarshalJSON implements json.Marshaler to provide an easy, simply default. +// MarshalJSON implements json.Marshaler to provide an easy, simple default. func (f Callers) MarshalJSON() ([]byte, error) { // JSON-able frame type - type frame struct { + type jsonFrame struct { Func string `json:"func"` File string `json:"file"` Line int `json:"line"` } - // Allocate expected frames slice - frames := make([]frame, 0, len(f)) + // Convert to frames + frames := f.Frames() - // Get frames iterator for PCs - iter := runtime.CallersFrames(f) + // Allocate expected size jsonFrame slice + jsonFrames := make([]jsonFrame, 0, len(f)) - for { - // Get next frame - f, ok := iter.Next() - if !ok { - break - } + for i := 0; i < len(frames); i++ { + frame := frames[i] - // Append to frames slice - frames = append(frames, frame{ - Func: funcname(f.Function), - File: f.File, - Line: f.Line, + // Convert each to jsonFrame object + jsonFrames = append(jsonFrames, jsonFrame{ + Func: funcname(frame.Function), + File: frame.File, + Line: frame.Line, }) } @@ -86,8 +82,8 @@ func (f Callers) String() string { frame := frames[i] // Append formatted caller info - funcname := funcname(frame.Function) - buf = append(buf, funcname+"()\n\t"+frame.File+":"...) + fn := funcname(frame.Function) + buf = append(buf, fn+"()\n\t"+frame.File+":"...) buf = strconv.AppendInt(buf, int64(frame.Line), 10) buf = append(buf, '\n') } |