location

package
v0.12.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 20, 2020 License: MIT Imports: 5 Imported by: 0

Documentation

Overview

Package location contains utilities for obtaining the function, file and line number of various Go types and values.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Location

type Location struct {
	// Func is the fully-qualified name of the function.
	//
	// The format of this string is not defined by this package and is subject
	// to change.
	Func string

	// File is the name of the Go source file.
	File string

	// Line is the line number within the file, starting at 1.
	Line int
}

Location describes a location within a code base.

Any of the fields may be zero-valued, indicating that piece of information is unknown.

func OfCall

func OfCall() Location

OfCall returns the location where its caller was called itself.

func OfFunc

func OfFunc(fn interface{}) Location

OfFunc returns the location of the definition of fn.

func OfMethod

func OfMethod(recv interface{}, m string) Location

OfMethod returns the location of the definition of fn.

func OfPanic

func OfPanic() Location

OfPanic returns the location of the call to panic() that caused the stack to start unwinding.

It must be called within a deferred function and only if recover() returned a non-nil value. Otherwise the behavior of the function is undefined.

func (Location) String

func (l Location) String() string

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL