Big News: Socket raises $60M Series C at a $1B valuation to secure software supply chains for AI-driven development.Announcement
Sign In

lukechampine.com/caller

Package Overview
Dependencies
Versions
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

lukechampine.com/caller

Go Modules
Version
v0.0.0-20190628162920-20dbcc501758
Version published
Created
Source

caller

caller is a simple utility package that provides nicely-formatting strings describing the callstack of a function invocation. Functionally, it serves the same purpose as runtime.Caller, but its output is easier to work with (one compact string, instead of four different types). Another convenience is that caller reports the name of the invoking function directly, instead of forcing you to look up the name manually using runtime.FuncForPC.

Example usage

// $GOPATH/src/github.com/username/example/example.go
package main

import "github.com/lukechampine/caller"

func foo() {
	for _, call := range caller.Trace(2) {
		println("\t" + call)
	}
}

func main() {
	println(caller.Get())
	println(caller.At(1))
	foo()
}

Output:

main (runtime/proc.c:247)
main (example/example.go:14)
	foo (example/example.go:7)
	main (example/example.go:15)

Full documentation can be found on godoc

FAQs

Package last updated on 28 Jun 2019

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts