Documentation ¶
Overview ¶
package sourceinfo is a helper around runtime Caller which simplifies fetching source information using frames.
Index ¶
Constants ¶
View Source
const (
DefaultCallDepth int = 1
)
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type SourceInfoType ¶
type SourceInfoType int
This enum indicates the source information format
const ( // Source information won't be retrieved NoSourceInfo SourceInfoType = iota // Full file name and line number FullFileAndLine // Full file name and line number with function name FullFileAndLineWithFunc // Short file name and line number ShortFileAndLine // Short file name and line number with function name ShortFileAndLineWithFunc )
type SourceInformation ¶
type SourceInformation struct { File string `json:"file" yaml:"file"` Function string `json:"function,omitempty" yaml:"function,omitempty"` Line int `json:"line" yaml:"line"` }
This structure contains the information about the source code.
func GetSourceInformation ¶
func GetSourceInformation(callDepth int, sourceInfoType SourceInfoType) (sourceInfo *SourceInformation)
This method gets the source information based on the type passed. Passing sourceinfo.NoSourceInfo will cause this function to return a nil pointer. If any error is encountered or if this function could not retrieve the source information then the returned pointer will be nil.
func (*SourceInformation) String ¶
func (s *SourceInformation) String() string
This function prints the source information in the format
file:line(function):
Click to show internal directories.
Click to hide internal directories.