Join GitHub today
GitHub is home to over 40 million developers working together to host and review code, manage projects, and build software together.Sign up
cmd/go: list the Go resources in a physical directory #30469
A lot of Go projects have been using the historical unpacked filesystem property of GOPATH to mix Go source files with other things (human documentation md files, non-Go resource files, etc).
This mixing does not make sense in module mode, since the Go compiler is the only thing that is smart enough to locate and access the content of module zip files.
Therefore there is a need to inspect existing Go project trees, to separate Go project source files from other things. And you have a bootstrapping problem, because GOPATH is not used in module mode, and the whole point of the inspection is to sort what must end up in the zip files, and what should end up elsewhere, so at this point the project is no longer in GOPATH but not in a zip module yet.
Is there a way to ask Go
Aside from calling
(Of course one could just zip brutally the whole tree and look what breaks afterwards, but that is not a very efficient way to switch to modules)
Hum, unless I'm missing something:
So you probably need to switch to the module directory root (because otherwise
which is not terribly convenient (and it is not even complete, there are other kinds of source files to add)
And having to os.exec