Skip to content
This repository has been archived by the owner on Jun 25, 2022. It is now read-only.

No box found when use go module #228

Open
bbiao opened this issue Aug 20, 2019 · 0 comments
Open

No box found when use go module #228

bbiao opened this issue Aug 20, 2019 · 0 comments

Comments

@bbiao
Copy link

bbiao commented Aug 20, 2019

GO111MODULE=on
GOPATH=/somewhere/go (this directory has no src subdirectory, only pkg and bin)

Project
 +--- cmd
          \--- app.go (import pkgA but has no box related codes)
 +--- pkgA
          \--- file_with_box.go (create box here)

when run packr2 under directory of Project/cmd, no box found

If disable gomodule(set GO111MODULE=off) and put Project into $GOPATH/src, and run packr2 under Project/cmd,every thing is ok

packr2 version: 2.5.2

===
I read and debugged the source code, and find there is some code in packr2/jam/parser/finder.go

		for _, imp := range pkg.Imports {
			if len(ctx.SrcDirs()) == 0 {
				continue
			}
=============================================
			d := ctx.SrcDirs()[len(ctx.SrcDirs())-1]
			ip := filepath.Join(d, imp)
=============================================
			n, err := fd.findAllGoFilesImports(ip)
			if err != nil && len(n) != 0 {
				names = n
				return
			}
			names = append(names, n...)
		}

Since the ip is joined by $GOPATH/src + import_dir,so if I use go-module from beginning and never have source code downloaded into the $GOPATH/src dir,the packr2 tool will fall to parse the source code.

Could I think that packr2 does not support pure go-module environment (without a $GOPATH/src directory) ?

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant