module that imports module error

149 views
Skip to first unread message

simon place

unread,
Apr 17, 2026, 9:57:07 AM (4 days ago) Apr 17
to golang-nuts
i'm 'replacing' modules, for development, with local ones, this has worked fine.

but now i am importing a module that itself imports another replaced module, i get 

'go: cycle imports
modulo: malformed module path "modulo": missing dot in first path element
'

i thought module names were just anything unique, only after uploading a URL.

and

'modulo' module path "modulo" can't be malformed when it builds/runs when being tested etc.


simon place

unread,
Apr 17, 2026, 9:59:43 AM (4 days ago) Apr 17
to golang-nuts
also dotless domains are provided for in the standard.

simon place

unread,
Apr 18, 2026, 9:40:12 AM (3 days ago) Apr 18
to golang-nuts
OK surprising fix....

you have to 'replace' any 'replaced' sub-imports.

in a module which imports a module that is replacing a module it uses, needs to included that sub-replacement, even thought it isn't used directly, which is to me surprising/unnecessary?

so, AFAICT, in a module chain, that uses a replacement somewhere, all go.mod's above where that replacement is changed, (name or reference) would need to be edited to reflect this.

Jason Phillips

unread,
Apr 19, 2026, 12:33:55 AM (3 days ago) Apr 19
to golang-nuts
From the replace directive documentation:
> replace directives only apply in the main module’s go.mod file and are ignored in other modules

The main module is the only module with control of the dependency graph.

Reply all
Reply to author
Forward
0 new messages