diff --git a/go/loader/loader.go b/go/loader/loader.go index 2a15359a..37181f26 100644 --- a/go/loader/loader.go +++ b/go/loader/loader.go @@ -460,6 +460,16 @@ func (prog *Program) InitialPackages() []*PackageInfo { return infos } +// FilePath returns the full path to the specified file. It returns the empty +// string if the file does not belong to one of this Program's packages. +// +func (prog *Program) FilePath(file *ast.File) string { + if f := prog.Fset.File(file.Package); f != nil { + return f.Name() + } + return "" +} + // ---------- Implementation ---------- // importer holds the working state of the algorithm.