From 97cf8c4210c6f6ddb66e42a1a81204445cb9b585 Mon Sep 17 00:00:00 2001 From: Denys Smirnov Date: Mon, 7 Nov 2022 17:22:12 +0200 Subject: [PATCH] Expose package name of a compiled source Exposing package name of the compiled source allows using it in `Eval`, as well as in logs and for other purposes. --- interp/program.go | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/interp/program.go b/interp/program.go index 28babbf7..90bbbe44 100644 --- a/interp/program.go +++ b/interp/program.go @@ -17,6 +17,11 @@ type Program struct { init []*node } +// PackageName returns name used in a package clause. +func (p *Program) PackageName() string { + return p.pkgName +} + // FileSet is the fileset that must be used for parsing Go that will be passed // to interp.CompileAST(). func (interp *Interpreter) FileSet() *token.FileSet {