Juan Marín
Juan Marín

Reputation: 91

malformed module path ... missing dot in first path element

I have a project with 2 different executables, each having it's own dependencies plus a shared dependency on the root, something like this:

Root
  |->server
  |    |-> main.go
  |    |-> someOtherFiles.go
  |    |-> go.mod
  |    |-> go.sum
  |->validator
  |    |-> main.go
  |    |-> someOtherFiles.go
  |    |-> go.mod
  |    |-> go.sum
  |->utils
  |    |-> someOtherFiles.go
  |->config
  |    |-> someOtherFiles.go
  |-> go.mod
  |-> go.sum

My root's go.mod is like this

module prex-kyc

go 1.13

require ({requiredDependencies})

And my validator's go.mod is like this (server's is analogue)

module validator

go 1.13

require (
    prex-kyc v0.0.0-00010101000000-000000000000
    {otherRequiredDependencies}
)

replace prex-kyc => ../

And in both validator's and server's main.go I do an import like this:

import (
    "prex-kyc/utils"
    {someOtherImports}
)

When I try to build either one of the projects i get this error: build validator: cannot load prex-kyc/config: malformed module path "prex-kyc/config": missing dot in first path element

I know there's nothing wrong with the code because it can be compiled in someone else's environment.

I have tried building using go versions 1.12 and 1.13 and both windows 10 and Debian Linux.

Upvotes: 5

Views: 17458

Answers (1)

Juan Marín
Juan Marín

Reputation: 91

[SOLVED]

The issue was that i was importing utils like this:

import("prex-kyc/utils")

But actually there was no package utils inside module prex-kyc, (only directory utils) and every .go files in that directory had a different package name. By changing each one of them to "package utils" the issue was solved.

The error "missing dot in first path element" was really misleading though

Upvotes: 4

Related Questions