Skip to content

Handling the case when runtime.Caller(2) returns ok as false in assert.go #2

@lazysegtree

Description

@lazysegtree

Since the skip value is always 2, and its probably guaranteed that runtime.Caller() will not fail due to skip being greater than number of stack frames. But I think could fail due to some unexpected issues - something specific to user system, or some memory corruption.

I think, it shouldn't hurt to add a check for the ok value, in case it is false, for a more complete error handling.

func Caller(skip int) (pc uintptr, file string, line int, ok bool)

The boolean ok is false if it was not possible to recover the information.

Reference :

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions