Skip to content

Commit

Permalink
Don't force the package to 'main' if the '-o' option was used.
Browse files Browse the repository at this point in the history
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 markbates#56.
  • Loading branch information
al45tair committed Mar 4, 2020
1 parent d9d5139 commit 160ff6d
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions cmd/pkger/cmds/pack.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}

Expand Down

0 comments on commit 160ff6d

Please sign in to comment.