From 160ff6da624facfaba462d2d734870cd9b922984 Mon Sep 17 00:00:00 2001 From: Alastair Houghton Date: Sat, 15 Feb 2020 21:24:42 +0000 Subject: [PATCH] Don't force the package to 'main' if the '-o' option was used. It looks like the problem is that pkger gets the information for the current directory, *then* appends the path from the '-o' option, but that means that the package name will always be main if it's started from the main package, regardless of '-o'. Fixes #56. --- cmd/pkger/cmds/pack.go | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/cmd/pkger/cmds/pack.go b/cmd/pkger/cmds/pack.go index 3961643..381029d 100644 --- a/cmd/pkger/cmds/pack.go +++ b/cmd/pkger/cmds/pack.go @@ -137,13 +137,14 @@ func Package(info here.Info, out string, decls parser.Decls) error { } defer f.Close() - c, err := here.Dir(filepath.Dir(out)) + dir := filepath.Dir(out) + c, err := here.Dir(dir) if err != nil { return err } name := c.Name - if info.Module.Main { + if dir == info.Dir && info.Module.Main { name = "main" }