Documentation ¶
Overview ¶
Package source 提供与 Go 源码相关的一些操作
Index ¶
- func CurrentDir() string
- func CurrentFile() string
- func CurrentFunction() string
- func CurrentLine() int
- func CurrentLocation() (path string, line int)
- func CurrentPath(path string) string
- func DumpStack(w io.Writer, skip int, msg ...any)
- func ModDir(p string) (string, error)
- func ModFile(p string) (string, *modfile.File, error)
- func PackagePath(p string) (string, error)
- func Stack(skip int, msg ...any) string
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CurrentFunction ¶
func CurrentFunction() string
CurrentFunction 获取`调用者`所在的函数名
相当于部分语言的 __FUNCTION__
func CurrentLocation ¶ added in v0.1.2
CurrentLocation 获取`调用者`当前的位置信息
func DumpStack ¶ added in v0.3.1
DumpStack 将调用的堆栈信息写入 w
skip 需要忽略的内容。
- 1 表示 Stack 自身;
- 2 表示 Stack 的调用者,以此类推;
msg 表示需要输出的额外信息;
func ModFile ¶ added in v0.4.0
ModFile 文件或目录 p 所在模块的 go.mod 内容
从当前目录开始依次向上查找 go.mod,从其中获取 go.mod 文件位置,以及文件内容的解析。
func PackagePath ¶ added in v0.8.0
PackagePath 文件或目录 p 所在 Go 文件的导出路径
会向上查找 go.mod,根据 go.mod 中的 module 结合当前目录组成当前目录的导出路径。
Types ¶
This section is empty.
Click to show internal directories.
Click to hide internal directories.