go/importer can't find github import referring to internal/ of current module

135 views
Skip to first unread message

Levieux Michel

unread,
Jun 14, 2021, 3:14:37 AM6/14/21
to golang-nuts
Hi guys,

Didn't really know what to put in the title, I have a file hierarchy like the following:
- gest (root of module)
-- cmd
--- gesterate
---- command files (see below)
-- internal
--- callstack
---- internal library files (see below)
-- library files (see below)

in the cmd/gesterate/ folder there is some code that should generate code upon calling go generate (it needs to be installed logically)
in the internal/callstack folder there is an internal library that is used by the library files in the root folder (gest/)

In order to test my code generation tool in cmd/gesterate, I put a //go generate ... pragma in one of my files in gest/, and tried to call go generate on the root folder. I use the go/importer package with the Default importer

It throws me the following error, which I'm having a hard time understanding where it comes from and why it is so:

The repo itself is private on github but I'll gladly share pieces of code if needed.
Thx in advance guys!

mlevi...@gmail.com

unread,
Jun 21, 2021, 3:31:46 AM6/21/21
to golang-nuts
Hi everyone,

In the absence of an answer, I reply here to make this thread go back to top.

For the moment I have worked around my issue by just adding a subdirectory in gest/ (see hierarchy above), and //go:generate'ing on this package. This works here because this sub-package does not import anything except std.
But, even if the problem is more specific than I think or I will never really use the fix, I'm curious as to why I observe the aforementioned behaviour.

If anyone could give some ideas / insights, it'd be great!

Thank you all in advance and please do not hesitate to ask for more precisions! :D
Reply all
Reply to author
Forward
0 new messages