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

No box found when use go module #228

@bbiao

Description

@bbiao

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) ?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions